Skip to content

Commit

Permalink
Merge pull request #8281 from microsoft/coleng/fix_no_folder_multiroo…
Browse files Browse the repository at this point in the history
…t_install_failure
  • Loading branch information
Colengms authored Oct 15, 2021
2 parents 0b94fde + a10a6d2 commit b0a82a8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Extension/src/LanguageServer/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export class CppProperties {
// not for each notifying folder.
const savedDocWorkspaceFolder: vscode.WorkspaceFolder | undefined = vscode.workspace.getWorkspaceFolder(doc.uri);
const notifyingWorkspaceFolder: vscode.WorkspaceFolder | undefined = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(settingsPath));
if ((!savedDocWorkspaceFolder && vscode.workspace.workspaceFolders && notifyingWorkspaceFolder === vscode.workspace.workspaceFolders[0])
if ((!savedDocWorkspaceFolder && vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 && notifyingWorkspaceFolder === vscode.workspace.workspaceFolders[0])
|| savedDocWorkspaceFolder === notifyingWorkspaceFolder) {
let fileType: string | undefined;
const documentPath: string = doc.uri.fsPath.toLowerCase();
Expand Down
2 changes: 1 addition & 1 deletion Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function sendActivationTelemetry(): void {
}

function realActivation(): void {
if (new CppSettings(vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri : undefined).intelliSenseEngine === "Disabled") {
if (new CppSettings((vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) ? vscode.workspace.workspaceFolders[0]?.uri : undefined).intelliSenseEngine === "Disabled") {
throw new Error(intelliSenseDisabledError);
} else {
console.log("activating extension");
Expand Down
2 changes: 1 addition & 1 deletion Extension/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ function getUniqueWorkspaceNameHelper(workspaceFolder: vscode.WorkspaceFolder, a
return workspaceFolderName; // No duplicate names to search for.
}
for (let i: number = 0; i < workspaceFolder.index; ++i) {
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders[i].name === workspaceFolderName) {
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 && vscode.workspace.workspaceFolders[i].name === workspaceFolderName) {
return addSubfolder ? path.join(workspaceFolderName, String(workspaceFolder.index)) : // Use the index as a subfolder.
workspaceFolderName + String(workspaceFolder.index);
}
Expand Down
2 changes: 1 addition & 1 deletion Extension/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ async function postInstall(info: PlatformInformation): Promise<void> {
}

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

0 comments on commit b0a82a8

Please sign in to comment.