Skip to content

Commit b0a82a8

Browse files
authored
Merge pull request #8281 from microsoft/coleng/fix_no_folder_multiroot_install_failure
2 parents 0b94fde + a10a6d2 commit b0a82a8

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

Extension/src/LanguageServer/configurations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export class CppProperties {
264264
// not for each notifying folder.
265265
const savedDocWorkspaceFolder: vscode.WorkspaceFolder | undefined = vscode.workspace.getWorkspaceFolder(doc.uri);
266266
const notifyingWorkspaceFolder: vscode.WorkspaceFolder | undefined = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(settingsPath));
267-
if ((!savedDocWorkspaceFolder && vscode.workspace.workspaceFolders && notifyingWorkspaceFolder === vscode.workspace.workspaceFolders[0])
267+
if ((!savedDocWorkspaceFolder && vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 && notifyingWorkspaceFolder === vscode.workspace.workspaceFolders[0])
268268
|| savedDocWorkspaceFolder === notifyingWorkspaceFolder) {
269269
let fileType: string | undefined;
270270
const documentPath: string = doc.uri.fsPath.toLowerCase();

Extension/src/LanguageServer/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ function sendActivationTelemetry(): void {
284284
}
285285

286286
function realActivation(): void {
287-
if (new CppSettings(vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri : undefined).intelliSenseEngine === "Disabled") {
287+
if (new CppSettings((vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) ? vscode.workspace.workspaceFolders[0]?.uri : undefined).intelliSenseEngine === "Disabled") {
288288
throw new Error(intelliSenseDisabledError);
289289
} else {
290290
console.log("activating extension");

Extension/src/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ function getUniqueWorkspaceNameHelper(workspaceFolder: vscode.WorkspaceFolder, a
12721272
return workspaceFolderName; // No duplicate names to search for.
12731273
}
12741274
for (let i: number = 0; i < workspaceFolder.index; ++i) {
1275-
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders[i].name === workspaceFolderName) {
1275+
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 && vscode.workspace.workspaceFolders[i].name === workspaceFolderName) {
12761276
return addSubfolder ? path.join(workspaceFolderName, String(workspaceFolder.index)) : // Use the index as a subfolder.
12771277
workspaceFolderName + String(workspaceFolder.index);
12781278
}

Extension/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ async function postInstall(info: PlatformInformation): Promise<void> {
393393
}
394394

395395
async function finalizeExtensionActivation(): Promise<void> {
396-
const settings: CppSettings = new CppSettings(vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri : undefined);
396+
const settings: CppSettings = new CppSettings((vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) ? vscode.workspace.workspaceFolders[0]?.uri : undefined);
397397
if (settings.intelliSenseEngine === "Disabled") {
398398
languageServiceDisabled = true;
399399
getTemporaryCommandRegistrarInstance().disableLanguageServer();

0 commit comments

Comments
 (0)