From 1c8b8f4d6db75e4b05359e87e20f78d685d3a52c Mon Sep 17 00:00:00 2001 From: Colen Garoutte-Carson <49173979+Colengms@users.noreply.github.com> Date: Fri, 13 Mar 2020 16:36:32 -0700 Subject: [PATCH] Fix error when renaming (#5114) --- Extension/CHANGELOG.md | 6 +++--- .../src/Debugger/configurationProvider.ts | 2 +- Extension/src/LanguageServer/client.ts | 1 + .../src/LanguageServer/configurations.ts | 2 +- Extension/src/LanguageServer/extension.ts | 2 +- .../src/LanguageServer/referencesModel.ts | 2 +- .../referencesTreeDataProvider.ts | 20 +++++++++---------- Extension/src/common.ts | 2 +- 8 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index 2811c56c6a..22bd27b999 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -1,6 +1,6 @@ # C/C++ for Visual Studio Code Change Log -## Version 0.27.0-insiders3: March 12, 2019 +## Version 0.27.0-insiders3: March 13, 2020 ### Bug Fixes * Fix update to clang-format 9.0.1 (and without shared library dependencies). [#2887](https://github.com/microsoft/vscode-cpptools/issues/2887), [#3174](https://github.com/microsoft/vscode-cpptools/issues/3174) * Add new setting `C_Cpp.debugger.useBacktickCommandSubstitution` to fix debugging when CShell is the remote default shell. [#4015](https://github.com/microsoft/vscode-cpptools/issues/4015) @@ -17,12 +17,12 @@ * Fix Pause (break all) not working on Mac with Attach debugging. * Other language server crash fixes. -## Version 0.27.0-insiders2: March 4, 2019 +## Version 0.27.0-insiders2: March 4, 2020 ### Bug Fixes * Fix the `Open File...` scenario (without a workspace folder). [#5049](https://github.com/microsoft/vscode-cpptools/issues/5049) * Fix `browsePath` null reference that can occur with some configuration providers. [PR #5055](https://github.com/microsoft/vscode-cpptools/pull/5055) -## Version 0.27.0-insiders: March 3, 2019 +## Version 0.27.0-insiders: March 3, 2020 ### Enhancements * Improved multi-root implementation with a single language server process and database for the entire workspace (shared between workspace folders). Fixes most [multi-root bugs](https://github.com/microsoft/vscode-cpptools/issues?q=is%3Aopen+is%3Aissue+label%3A%22Feature%3A+Multiroot%22+label%3A%22fixed+%28release+pending%29%22+milestone%3A0.27.0). * Update to clang-format 9.0.1 (and without shared library dependencies). [#2887](https://github.com/microsoft/vscode-cpptools/issues/2887), [#3174](https://github.com/microsoft/vscode-cpptools/issues/3174) diff --git a/Extension/src/Debugger/configurationProvider.ts b/Extension/src/Debugger/configurationProvider.ts index c31d0f1572..8d8e64113b 100644 --- a/Extension/src/Debugger/configurationProvider.ts +++ b/Extension/src/Debugger/configurationProvider.ts @@ -70,7 +70,7 @@ export class QuickPickConfigurationProvider implements vscode.DebugConfiguration throw new Error(); // User canceled it. } if (selection.label.startsWith("cl.exe")) { - if (!process.env.DevEnvDir || process.env.DevEnvDir.length === 0) { + if (!process.env.DevEnvDir) { vscode.window.showErrorMessage(localize("cl.exe.not.available", "{0} build and debug is only usable when VS Code is run from the Developer Command Prompt for VS.", "cl.exe")); throw new Error(); } diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index b5e6e2bbf8..ab49ae627f 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -593,6 +593,7 @@ export class DefaultClient implements Client { storagePath = path; } } + if (!storagePath) { storagePath = path.join(this.RootPath, "/.vscode"); } diff --git a/Extension/src/LanguageServer/configurations.ts b/Extension/src/LanguageServer/configurations.ts index ed57524bf6..440465607c 100644 --- a/Extension/src/LanguageServer/configurations.ts +++ b/Extension/src/LanguageServer/configurations.ts @@ -1291,7 +1291,7 @@ export class CppProperties { if (isWindows && compilerPathAndArgs.compilerName === "cl.exe") { continue; // Don't squiggle invalid cl.exe paths because it could be for an older preview build. } - if (!compilerPathAndArgs.compilerPath) { + if (compilerPathAndArgs.compilerPath === undefined) { continue; } // Squiggle when the compiler's path has spaces without quotes but args are used. diff --git a/Extension/src/LanguageServer/extension.ts b/Extension/src/LanguageServer/extension.ts index 637d6fcc91..74072d2e60 100644 --- a/Extension/src/LanguageServer/extension.ts +++ b/Extension/src/LanguageServer/extension.ts @@ -1254,7 +1254,7 @@ function onRenameViewAddFile(arg?: TreeNode): void { } function onRenameViewAddReferenceType(arg?: TreeNode): void { - if (!arg || !arg.referenceType) { + if (!arg || arg.referenceType === undefined) { return; } arg.model.setAllReferenceTypeRenamesPending(arg.referenceType); diff --git a/Extension/src/LanguageServer/referencesModel.ts b/Extension/src/LanguageServer/referencesModel.ts index a9ea695feb..627b6ef41b 100644 --- a/Extension/src/LanguageServer/referencesModel.ts +++ b/Extension/src/LanguageServer/referencesModel.ts @@ -277,7 +277,7 @@ export class ReferencesModel { let referenceInfos: ReferenceInfo[] = []; this.nodes.forEach(n => { if (!n.isRenameCandidate) { - if (!n.filename || !n.referenceLocation || !n.referenceText || !n.referenceType) { + if (!n.filename || !n.referenceLocation || n.referenceText === undefined || n.referenceType === undefined) { throw new Error("Invalid TreeNode detected in completeRename()"); } let referenceInfo: ReferenceInfo = { diff --git a/Extension/src/LanguageServer/referencesTreeDataProvider.ts b/Extension/src/LanguageServer/referencesTreeDataProvider.ts index 5a22a6cb65..8e1424ad87 100644 --- a/Extension/src/LanguageServer/referencesTreeDataProvider.ts +++ b/Extension/src/LanguageServer/referencesTreeDataProvider.ts @@ -75,14 +75,14 @@ export class ReferencesTreeDataProvider implements vscode.TreeDataProvider