Skip to content

Commit 6272b82

Browse files
committed
Notify build is preparing before progress starts
The build progress notification would only appear once the progress values were shown in the output, i.e. [12/122]. Until progress values appear, show a "Preparing <task>" notification. This only needs to apply when the `showBuildStatus` value is `notification` or `progress`, since `swiftStatus` already shows a message in the bar immediately. This patch also only sets the `showBuildStatus` setting on a Task if it is coming from a user defined task. Previously it was being set on synthetic tasks which were being cached, so when the user updated the `showBuildStatus` setting it wouldn't take effect until they restarted the extension. Issue: swiftlang#1322
1 parent 6f426e1 commit 6272b82

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

src/SwiftSnippets.ts

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ export async function debugSnippetWithOptions(
8282
presentationOptions: {
8383
reveal: vscode.TaskRevealKind.Always,
8484
},
85-
showBuildStatus: configuration.showBuildStatus,
8685
},
8786
ctx.toolchain
8887
);

src/tasks/SwiftTaskProvider.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ export function createBuildAllTask(
155155
reveal: getBuildRevealOption(),
156156
},
157157
disableTaskQueue: true,
158-
showBuildStatus: configuration.showBuildStatus,
159158
},
160159
folderContext.workspaceContext.toolchain
161160
);
@@ -239,7 +238,6 @@ function createBuildTasks(product: Product, folderContext: FolderContext): vscod
239238
},
240239
disableTaskQueue: true,
241240
dontTriggerTestDiscovery: true,
242-
showBuildStatus: configuration.showBuildStatus,
243241
},
244242
folderContext.workspaceContext.toolchain
245243
);
@@ -268,7 +266,6 @@ function createBuildTasks(product: Product, folderContext: FolderContext): vscod
268266
},
269267
disableTaskQueue: true,
270268
dontTriggerTestDiscovery: true,
271-
showBuildStatus: configuration.showBuildStatus,
272269
},
273270
folderContext.workspaceContext.toolchain
274271
);
@@ -314,9 +311,15 @@ export function createSwiftTask(
314311
args: args,
315312
env: env,
316313
cwd: cwd,
317-
showBuildStatus: config.showBuildStatus,
318-
disableTaskQueue: config.disableTaskQueue,
319-
dontTriggerTestDiscovery: config.dontTriggerTestDiscovery,
314+
...(config.showBuildStatus !== undefined
315+
? { showBuildStatus: config.showBuildStatus }
316+
: {}),
317+
...(config.disableTaskQueue !== undefined
318+
? { disableTaskQueue: config.disableTaskQueue }
319+
: {}),
320+
...(config.dontTriggerTestDiscovery !== undefined
321+
? { dontTriggerTestDiscovery: config.dontTriggerTestDiscovery }
322+
: {}),
320323
},
321324
config?.scope ?? vscode.TaskScope.Workspace,
322325
name,

src/ui/SwiftBuildStatus.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ export class SwiftBuildStatus implements vscode.Disposable {
7171
disposables.forEach(d => d.dispose());
7272
res();
7373
};
74+
const state = { started: false };
7475
disposables.push(
7576
execution.onDidWrite(data => {
76-
if (this.parseEvents(task, data, update)) {
77+
if (this.parseEvents(task, data, showBuildStatus, update, state)) {
7778
done();
7879
}
7980
}),
@@ -109,7 +110,9 @@ export class SwiftBuildStatus implements vscode.Disposable {
109110
private parseEvents(
110111
task: vscode.Task,
111112
data: string,
112-
update: (message: string) => void
113+
showBuildStatus: ShowBuildStatusOptions,
114+
update: (message: string) => void,
115+
state: { started: boolean }
113116
): boolean {
114117
const name = new RunningTask(task).name;
115118
const sanitizedData = stripAnsi(data);
@@ -124,14 +127,27 @@ export class SwiftBuildStatus implements vscode.Disposable {
124127
const progress = this.findBuildProgress(line);
125128
if (progress) {
126129
update(`${name} [${progress.completed}/${progress.total}]`);
130+
state.started = true;
127131
return false;
128132
}
129133
if (this.checkIfFetching(line)) {
130134
// this.statusItem.update(task, `Fetching dependencies "${task.name}"`);
131-
update(`${name} fetching dependencies`);
135+
update(`${name}: fetching dependencies`);
136+
state.started = true;
132137
return false;
133138
}
134139
}
140+
// If we've found nothing that matches a known state then put up a temporary
141+
// message that we're preparing the build, as there is sometimes a delay before
142+
// building starts while the build system is preparing, especially in large projects.
143+
// The status bar has a message immediately, so only show this when using a
144+
// notification to show progress.
145+
if (
146+
!state.started &&
147+
(showBuildStatus === "notification" || showBuildStatus === "progress")
148+
) {
149+
update(`Preparing ${name}`);
150+
}
135151
return false;
136152
}
137153

0 commit comments

Comments
 (0)