Skip to content

Notify build is preparing before progress starts #1323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/SwiftSnippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { createSwiftTask } from "./tasks/SwiftTaskProvider";
import { WorkspaceContext } from "./WorkspaceContext";
import { createSnippetConfiguration, debugLaunchConfig } from "./debugger/launch";
import { TaskOperation } from "./tasks/TaskQueue";
import configuration from "./configuration";

/**
* Set context key indicating whether current file is a Swift Snippet
Expand Down Expand Up @@ -82,7 +81,6 @@ export async function debugSnippetWithOptions(
presentationOptions: {
reveal: vscode.TaskRevealKind.Always,
},
showBuildStatus: configuration.showBuildStatus,
},
ctx.toolchain
);
Expand Down
15 changes: 9 additions & 6 deletions src/tasks/SwiftTaskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ export function createBuildAllTask(
reveal: getBuildRevealOption(),
},
disableTaskQueue: true,
showBuildStatus: configuration.showBuildStatus,
},
folderContext.workspaceContext.toolchain
);
Expand Down Expand Up @@ -239,7 +238,6 @@ function createBuildTasks(product: Product, folderContext: FolderContext): vscod
},
disableTaskQueue: true,
dontTriggerTestDiscovery: true,
showBuildStatus: configuration.showBuildStatus,
},
folderContext.workspaceContext.toolchain
);
Expand Down Expand Up @@ -268,7 +266,6 @@ function createBuildTasks(product: Product, folderContext: FolderContext): vscod
},
disableTaskQueue: true,
dontTriggerTestDiscovery: true,
showBuildStatus: configuration.showBuildStatus,
},
folderContext.workspaceContext.toolchain
);
Expand Down Expand Up @@ -314,9 +311,15 @@ export function createSwiftTask(
args: args,
env: env,
cwd: cwd,
showBuildStatus: config.showBuildStatus,
disableTaskQueue: config.disableTaskQueue,
dontTriggerTestDiscovery: config.dontTriggerTestDiscovery,
...(config.showBuildStatus !== undefined
? { showBuildStatus: config.showBuildStatus }
: {}),
...(config.disableTaskQueue !== undefined
? { disableTaskQueue: config.disableTaskQueue }
: {}),
...(config.dontTriggerTestDiscovery !== undefined
? { dontTriggerTestDiscovery: config.dontTriggerTestDiscovery }
: {}),
},
config?.scope ?? vscode.TaskScope.Workspace,
name,
Expand Down
22 changes: 19 additions & 3 deletions src/ui/SwiftBuildStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ export class SwiftBuildStatus implements vscode.Disposable {
disposables.forEach(d => d.dispose());
res();
};
const state = { started: false };
disposables.push(
execution.onDidWrite(data => {
if (this.parseEvents(task, data, update)) {
if (this.parseEvents(task, data, showBuildStatus, update, state)) {
done();
}
}),
Expand Down Expand Up @@ -109,7 +110,9 @@ export class SwiftBuildStatus implements vscode.Disposable {
private parseEvents(
task: vscode.Task,
data: string,
update: (message: string) => void
showBuildStatus: ShowBuildStatusOptions,
update: (message: string) => void,
state: { started: boolean }
): boolean {
const name = new RunningTask(task).name;
const sanitizedData = stripAnsi(data);
Expand All @@ -124,14 +127,27 @@ export class SwiftBuildStatus implements vscode.Disposable {
const progress = this.findBuildProgress(line);
if (progress) {
update(`${name} [${progress.completed}/${progress.total}]`);
state.started = true;
return false;
}
if (this.checkIfFetching(line)) {
// this.statusItem.update(task, `Fetching dependencies "${task.name}"`);
update(`${name} fetching dependencies`);
update(`${name}: fetching dependencies`);
state.started = true;
return false;
}
}
// If we've found nothing that matches a known state then put up a temporary
// message that we're preparing the build, as there is sometimes a delay before
// building starts while the build system is preparing, especially in large projects.
// The status bar has a message immediately, so only show this when using a
// notification to show progress.
if (
!state.started &&
(showBuildStatus === "notification" || showBuildStatus === "progress")
) {
update(`Preparing ${name}`);
}
return false;
}

Expand Down
Loading