From 1eb064e0200298ed169bc8e37abeffdb9b1f5655 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Wed, 20 Mar 2019 15:39:06 -0700 Subject: [PATCH 1/3] Build tasks.json deletion. Configure Task. (#3328) * Build tasks.json deletion. Configure Task. --- Extension/CHANGELOG.md | 4 ++++ Extension/package.json | 2 +- Extension/src/Debugger/configurationProvider.ts | 2 +- Extension/src/Debugger/extension.ts | 5 ++++- Extension/src/LanguageServer/extension.ts | 8 ++++++-- Extension/src/common.ts | 16 +++++++--------- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index 41065333f2..d42edfa657 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -1,5 +1,9 @@ # C/C++ for Visual Studio Code Change Log +## Version 0.22.1: March 20, 2019 +* Fix `tasks.json` with single-line comments being overwritten when `Build and Debug Active File` is used. [#3327](https://github.com/Microsoft/vscode-cpptools/issues/3327) +* Fix an invalid `compilerPath` property getting added to `tasks.json` after doing `Configure Task` with a C/C++ compiler. + ## Version 0.22.0: March 19, 2019 ### Major Changes * Add warning squiggles for invalid properties and paths in `c_cpp_properties.json`. [#2799](https://github.com/Microsoft/vscode-cpptools/issues/2799), [PR #3283](https://github.com/Microsoft/vscode-cpptools/pull/3283) diff --git a/Extension/package.json b/Extension/package.json index dc04bf7c6f..8eb986ac07 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.22.0-master", + "version": "0.22.1-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 55fb345a41..cae5c18c88 100644 --- a/Extension/src/Debugger/configurationProvider.ts +++ b/Extension/src/Debugger/configurationProvider.ts @@ -94,7 +94,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 | undefined, token?: vscode.CancellationToken): Promise { - let buildTasks: vscode.Task[] = await getBuildTasks(); + let buildTasks: vscode.Task[] = await getBuildTasks(true); if (buildTasks.length === 0) { return Promise.resolve(this.provider.getInitialConfigurations(this.type)); } diff --git a/Extension/src/Debugger/extension.ts b/Extension/src/Debugger/extension.ts index 5208b1c65f..1779fc8895 100644 --- a/Extension/src/Debugger/extension.ts +++ b/Extension/src/Debugger/extension.ts @@ -91,12 +91,15 @@ export function initialize(context: vscode.ExtensionContext): void { await util.ensureBuildTaskExists(selection.configuration.preLaunchTask); Telemetry.logDebuggerEvent("buildAndDebug", { "success": "false" }); } catch (e) { + if (e && e.message === util.failedToParseTasksJson) { + vscode.window.showErrorMessage(util.failedToParseTasksJson); + } return Promise.resolve(); } } else { return Promise.resolve(); // TODO uncomment this when single file mode works correctly. - // const buildTasks: vscode.Task[] = await getBuildTasks(); + // const buildTasks: vscode.Task[] = await getBuildTasks(true); // const task: vscode.Task = buildTasks.find(task => task.name === selection.configuration.preLaunchTask); // await vscode.tasks.executeTask(task); // delete selection.configuration.preLaunchTask; diff --git a/Extension/src/LanguageServer/extension.ts b/Extension/src/LanguageServer/extension.ts index 0a875c0516..c49975a7f4 100644 --- a/Extension/src/LanguageServer/extension.ts +++ b/Extension/src/LanguageServer/extension.ts @@ -71,7 +71,7 @@ export function activate(activationEventOccurred: boolean): void { taskProvider = vscode.tasks.registerTaskProvider(taskSourceStr, { provideTasks: () => { - return getBuildTasks(); + return getBuildTasks(false); }, resolveTask(task: vscode.Task): vscode.Task { // Currently cannot implement because VS Code does not call this. Can implement custom output file directory when enabled. @@ -114,7 +114,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(): Promise { +export async function getBuildTasks(returnComplerPath: boolean): Promise { const editor: vscode.TextEditor = vscode.window.activeTextEditor; if (!editor) { return []; @@ -243,6 +243,10 @@ export async function getBuildTasks(): Promise { task.definition = kind; // The constructor for vscode.Task will eat the definition. Reset it by reassigning. task.group = vscode.TaskGroup.Build; + if (!returnComplerPath) { + delete task.definition.compilerPath; + } + return task; }); } diff --git a/Extension/src/common.ts b/Extension/src/common.ts index 620a5883f5..a357f34fd5 100644 --- a/Extension/src/common.ts +++ b/Extension/src/common.ts @@ -23,6 +23,8 @@ export function setExtensionContext(context: vscode.ExtensionContext): void { extensionContext = context; } +export const failedToParseTasksJson: string = "Failed to parse tasks.json, possibly due to comments or trailing commas."; + // Use this package.json to read values export const packageJson: any = vscode.extensions.getExtension("ms-vscode.cpptools").packageJSON; @@ -47,11 +49,13 @@ export function getRawTasksJson(): Promise { if (!exists) { return resolve({}); } - const fileContents: Buffer = fs.readFileSync(path); + let fileContents: string = fs.readFileSync(path).toString(); + fileContents = fileContents.replace(/^\s*\/\/.*$/gm, ""); // Remove start of line // comments. let rawTasks: any = {}; try { - rawTasks = JSON.parse(fileContents.toString()); + rawTasks = JSON.parse(fileContents); } catch (error) { + return reject(new Error(failedToParseTasksJson)); } resolve(rawTasks); }); @@ -73,16 +77,10 @@ export async function ensureBuildTaskExists(taskName: string): Promise { return; } - const buildTasks: vscode.Task[] = await getBuildTasks(); + const buildTasks: vscode.Task[] = await getBuildTasks(false); selectedTask = buildTasks.find(task => task.name === taskName); console.assert(selectedTask); - let definition: vscode.TaskDefinition = selectedTask.definition as vscode.TaskDefinition; - if (definition && definition.compilerPath) { - // TODO: add desired properties to empty object, don't delete. - delete definition.compilerPath; - } - rawTasksJson.version = "2.0.0"; if (!rawTasksJson.tasks.find(task => { return task.label === selectedTask.definition.label; })) { From 798e90574cdbdc85795c555832c22d1715e7abde Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Wed, 20 Mar 2019 18:24:13 -0700 Subject: [PATCH 2/3] Update for 0.22.1. (#3331) --- Extension/CHANGELOG.md | 3 ++- Extension/ReleaseNotes.html | 2 +- Extension/package.json | 8 ++++---- Extension/src/LanguageServer/client.ts | 12 +++++------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index d42edfa657..f9ebbee4ed 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -1,8 +1,9 @@ # C/C++ for Visual Studio Code Change Log -## Version 0.22.1: March 20, 2019 +## Version 0.22.1: March 21, 2019 * Fix `tasks.json` with single-line comments being overwritten when `Build and Debug Active File` is used. [#3327](https://github.com/Microsoft/vscode-cpptools/issues/3327) * Fix an invalid `compilerPath` property getting added to `tasks.json` after doing `Configure Task` with a C/C++ compiler. +* Add IntelliSense caching for macOS 10.13 or later (0.22.0 only supported Windows and Linux). ## Version 0.22.0: March 19, 2019 ### Major Changes diff --git a/Extension/ReleaseNotes.html b/Extension/ReleaseNotes.html index e6156f2c04..82ecaadbbd 100644 --- a/Extension/ReleaseNotes.html +++ b/Extension/ReleaseNotes.html @@ -208,7 +208,7 @@

Microsoft C/C++ Extension for VS Code

March 2019 Update

Thank you for installing the C/C++ extension! We're excited to announce the following features in the March update:

IntelliSense caching

- On Windows and Linux, the extension will now cache header information to improve IntelliSense speed for your code files. Support for macOS will be available in a future release.
+ The extension will now cache header information to improve IntelliSense speed for your code files.

Please Note: The extension writes the cache to disk in order to achieve this performance improvement. By default the cache files will be stored in your workspace folder's ".vscode" folder, but you can change this location by using the "C_Cpp.intelliSenseCachePath" setting. You can also control how much disk space can be diff --git a/Extension/package.json b/Extension/package.json index 8eb986ac07..2b8572f6bd 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -1451,7 +1451,7 @@ "runtimeDependencies": [ { "description": "C/C++ language components (Linux / x86_64)", - "url": "https://go.microsoft.com/fwlink/?linkid=2065016", + "url": "https://go.microsoft.com/fwlink/?linkid=2084924", "platforms": [ "linux" ], @@ -1465,7 +1465,7 @@ }, { "description": "C/C++ language components (Linux / x86)", - "url": "https://go.microsoft.com/fwlink/?linkid=2065017", + "url": "https://go.microsoft.com/fwlink/?linkid=2085028", "platforms": [ "linux" ], @@ -1481,7 +1481,7 @@ }, { "description": "C/C++ language components (OS X)", - "url": "https://go.microsoft.com/fwlink/?linkid=2064955", + "url": "https://go.microsoft.com/fwlink/?linkid=2084925", "platforms": [ "darwin" ], @@ -1492,7 +1492,7 @@ }, { "description": "C/C++ language components (Windows)", - "url": "https://go.microsoft.com/fwlink/?linkid=2065027", + "url": "https://go.microsoft.com/fwlink/?linkid=2085027", "platforms": [ "win32" ], diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index ef6f759710..cb25e28bbe 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -383,13 +383,11 @@ class DefaultClient implements Client { let intelliSenseCacheDisabled: boolean = false; if (os.platform() === "darwin") { - intelliSenseCacheDisabled = true; - // TODO: Re-enable this after the performance is improved on Mac. - //const releaseParts: string[] = os.release().split("."); - //if (releaseParts.length >= 1) { - // // AutoPCH doesn't work for older Mac OS's. - // intelliSenseCacheDisabled = parseInt(releaseParts[0]) < 17; - //} + const releaseParts: string[] = os.release().split("."); + if (releaseParts.length >= 1) { + // AutoPCH doesn't work for older Mac OS's. + intelliSenseCacheDisabled = parseInt(releaseParts[0]) < 17; + } } let clientOptions: LanguageClientOptions = { From 6724e13c631dcfee97cd2e440916c27df7f1bf89 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Wed, 20 Mar 2019 18:44:44 -0700 Subject: [PATCH 3/3] Update for 0.22.1. --- Extension/package-lock.json | 2 +- Extension/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Extension/package-lock.json b/Extension/package-lock.json index 2d99963562..e13a5f2671 100644 --- a/Extension/package-lock.json +++ b/Extension/package-lock.json @@ -1,6 +1,6 @@ { "name": "cpptools", - "version": "0.22.0-master", + "version": "0.22.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/Extension/package.json b/Extension/package.json index 2b8572f6bd..8e92302964 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.22.1-master", + "version": "0.22.1", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png",