diff --git a/Extension/package.json b/Extension/package.json index 0fec31404..3db166950 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "cpptools", "displayName": "C/C++", "description": "C/C++ IntelliSense, debugging, and code browsing.", - "version": "0.28.1-master", + "version": "0.28.2-master", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png", diff --git a/Extension/src/Debugger/configurationProvider.ts b/Extension/src/Debugger/configurationProvider.ts index 8d8e64113..35ad0ce05 100644 --- a/Extension/src/Debugger/configurationProvider.ts +++ b/Extension/src/Debugger/configurationProvider.ts @@ -105,7 +105,7 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider { * Returns a list of initial debug configurations based on contextual information, e.g. package.json or folder. */ async provideDebugConfigurations(folder?: vscode.WorkspaceFolder, token?: vscode.CancellationToken): Promise { - let buildTasks: vscode.Task[] = await getBuildTasks(true); + let buildTasks: vscode.Task[] = await getBuildTasks(true, true); if (buildTasks.length === 0) { return Promise.resolve(this.provider.getInitialConfigurations(this.type)); } @@ -119,11 +119,11 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider { // Filter out build tasks that don't match the currently selected debug configuration type. buildTasks = buildTasks.filter((task: vscode.Task) => { if (defaultConfig.name.startsWith("(Windows) ")) { - if (task.name.startsWith("cl.exe")) { + if (task.name.startsWith("C/C++: cl.exe")) { return true; } } else { - if (!task.name.startsWith("cl.exe")) { + if (!task.name.startsWith("C/C++: cl.exe")) { return true; } } diff --git a/Extension/src/LanguageServer/extension.ts b/Extension/src/LanguageServer/extension.ts index 4bd138a7f..a273222b7 100644 --- a/Extension/src/LanguageServer/extension.ts +++ b/Extension/src/LanguageServer/extension.ts @@ -47,7 +47,8 @@ let realActivationOccurred: boolean = false; let tempCommands: vscode.Disposable[] = []; let activatedPreviously: PersistentWorkspaceState; let buildInfoCache: BuildInfo | undefined; -const taskSourceStr: string = "shell"; +const taskTypeStr: string = "shell"; +const taskSourceStr: string = "C/C++"; const cppInstallVsixStr: string = 'C/C++: Install vsix -- '; let taskProvider: vscode.Disposable; let codeActionProvider: vscode.Disposable; @@ -171,8 +172,8 @@ export function activate(activationEventOccurred: boolean): void { return; } - taskProvider = vscode.tasks.registerTaskProvider(taskSourceStr, { - provideTasks: () => getBuildTasks(false), + taskProvider = vscode.tasks.registerTaskProvider(taskTypeStr, { + provideTasks: () => getBuildTasks(false, false), resolveTask(task: vscode.Task): vscode.Task | undefined { // Currently cannot implement because VS Code does not call this. Can implement custom output file directory when enabled. return undefined; @@ -243,7 +244,7 @@ export interface BuildTaskDefinition extends vscode.TaskDefinition { /** * Generate tasks to build the current file based on the user's detected compilers, the user's compilerPath setting, and the current file's extension. */ -export async function getBuildTasks(returnCompilerPath: boolean): Promise { +export async function getBuildTasks(returnCompilerPath: boolean, appendSourceToName: boolean): Promise { const editor: vscode.TextEditor | undefined = vscode.window.activeTextEditor; if (!editor) { return []; @@ -345,20 +346,20 @@ export async function getBuildTasks(returnCompilerPath: boolean): Promise vscode.Task = (compilerPath: string, compilerArgs?: string []) => { const filePath: string = path.join('${fileDirname}', '${fileBasenameNoExtension}'); const compilerPathBase: string = path.basename(compilerPath); - const taskName: string = compilerPathBase + " build active file"; + const taskName: string = (appendSourceToName ? taskSourceStr + ": " : "") + compilerPathBase + " build active file"; const isCl: boolean = compilerPathBase === "cl.exe"; - const cwd: string = isCl ? "" : path.dirname(compilerPath); + const cwd: string = "${workspaceFolder}"; let args: string[] = isCl ? ['/Zi', '/EHsc', '/Fe:', filePath + '.exe', '${file}'] : ['-g', '${file}', '-o', filePath + (isWindows ? '.exe' : '')]; if (compilerArgs && compilerArgs.length > 0) { args = args.concat(compilerArgs); } let kind: vscode.TaskDefinition = { - type: 'shell', + type: taskTypeStr, label: taskName, command: isCl ? compilerPathBase : compilerPath, args: args, - options: isCl ? undefined : {"cwd": cwd} + options: { "cwd": cwd } }; if (returnCompilerPath) { diff --git a/Extension/src/common.ts b/Extension/src/common.ts index a31c8c056..5b9d06b6f 100644 --- a/Extension/src/common.ts +++ b/Extension/src/common.ts @@ -96,7 +96,7 @@ export async function ensureBuildTaskExists(taskName: string): Promise { return; } - const buildTasks: vscode.Task[] = await getBuildTasks(false); + const buildTasks: vscode.Task[] = await getBuildTasks(false, true); selectedTask = buildTasks.find(task => task.name === taskName); console.assert(selectedTask); if (!selectedTask) { @@ -107,7 +107,12 @@ export async function ensureBuildTaskExists(taskName: string): Promise { let selectedTask2: vscode.Task = selectedTask; if (!rawTasksJson.tasks.find((task: any) => task.label === selectedTask2.definition.label)) { - rawTasksJson.tasks.push(selectedTask2.definition); + let task: any = { + ...selectedTask2.definition, + problemMatcher: selectedTask2.problemMatchers, + group: { kind: "build", "isDefault": true } + }; + rawTasksJson.tasks.push(task); } // TODO: It's dangerous to overwrite this file. We could be wiping out comments.