diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index 41065333f2..f9ebbee4ed 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -1,5 +1,10 @@ # C/C++ for Visual Studio Code Change Log +## 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 * 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/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-lock.json b/Extension/package-lock.json index ef8d950965..e13a5f2671 100644 --- a/Extension/package-lock.json +++ b/Extension/package-lock.json @@ -1,6 +1,6 @@ { "name": "cpptools", - "version": "0.22.0", + "version": "0.22.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/Extension/package.json b/Extension/package.json index 2c2a0fdfa1..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.0", + "version": "0.22.1", "publisher": "ms-vscode", "preview": true, "icon": "LanguageCCPP_color_128x.png", @@ -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/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/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 = { 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; })) {