in src/services/sqlTasksService.ts [129:172]
private async handleTaskChangedNotification(taskProgressInfo: TaskProgressInfo): Promise<void> {
const taskInfo = this._activeTasks.get(taskProgressInfo.taskId);
if (!taskInfo) {
console.warn(`Status update for unknown task ${taskProgressInfo.taskId}`!);
return;
}
const taskStatusString = toTaskStatusDisplayString(taskProgressInfo.status);
if (taskProgressInfo.message && (taskProgressInfo.message.toLowerCase() !== taskStatusString.toLowerCase())) {
taskInfo.lastMessage = taskProgressInfo.message;
}
if (isTaskCompleted(taskProgressInfo.status)) {
// Task is completed, complete the progress notification and display a final toast informing the
// user of the final status.
this._activeTasks.delete(taskProgressInfo.taskId);
if (taskProgressInfo.status === TaskStatus.Canceled) {
taskInfo.completionPromise.reject(new Error('Task cancelled'));
} else {
taskInfo.completionPromise.resolve();
}
// Get the message to display, if the last status doesn't have a valid message then get the last valid one
const lastMessage = (taskProgressInfo.message && taskProgressInfo.message.toLowerCase() !== taskStatusString.toLowerCase()) ?? taskInfo.lastMessage;
// Only include the message if it isn't the same as the task status string we already have - some (but not all) task status
// notifications include this string as the message
const taskMessage = lastMessage ?
utils.formatString(localizedConstants.taskStatusWithNameAndMessage, taskInfo.taskInfo.name, taskStatusString, lastMessage) :
utils.formatString(localizedConstants.taskStatusWithName, taskInfo.taskInfo.name, taskStatusString);
showCompletionMessage(taskProgressInfo.status, taskMessage);
if (taskInfo.taskInfo.taskExecutionMode === TaskExecutionMode.script && taskProgressInfo.script) {
await this._untitledSqlDocumentService.newQuery(taskProgressInfo.script);
}
} else {
// Task is still ongoing so just update the progress notification with the latest status
// The progress notification already has the name, so we just need to update the message with the latest status info.
// Only include the message if it isn't the same as the task status string we already have - some (but not all) task status
// notifications include this string as the message
const taskMessage = taskProgressInfo.message && taskProgressInfo.message.toLowerCase() !== taskStatusString.toLowerCase() ?
utils.formatString(localizedConstants.taskStatusWithMessage, taskInfo.taskInfo.name, taskStatusString, taskProgressInfo.message) :
taskStatusString;
taskInfo.progressCallback({ message: taskMessage });
}
}