diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index 2d0f7a41f..a6feab2de 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -118,6 +118,10 @@ "View Debug Docs": "View Debug Docs", "Ignore": "Ignore", "Run and Debug: A valid browser is not installed": "Run and Debug: A valid browser is not installed", + "Your workspace has multiple Visual Studio Solution files; please select one to get full IntelliSense.": "Your workspace has multiple Visual Studio Solution files; please select one to get full IntelliSense.", + "Choose": "Choose", + "Choose and set default": "Choose and set default", + "Do not load any": "Do not load any", "Restart Language Server": "Restart Language Server", "pipeArgs must be a string or a string array type": "pipeArgs must be a string or a string array type", "Name not defined in current configuration.": "Name not defined in current configuration.", diff --git a/src/lsptoolshost/commands.ts b/src/lsptoolshost/commands.ts index 8b3e8d25b..b70c726a3 100644 --- a/src/lsptoolshost/commands.ts +++ b/src/lsptoolshost/commands.ts @@ -146,9 +146,9 @@ async function completionComplexEdit( } } -async function openSolution(languageServer: RoslynLanguageServer): Promise { +async function openSolution(languageServer: RoslynLanguageServer): Promise { if (!vscode.workspace.workspaceFolders) { - return; + return undefined; } const solutionFiles = await vscode.workspace.findFiles('**/*.sln'); @@ -159,6 +159,8 @@ async function openSolution(languageServer: RoslynLanguageServer): Promise }); if (launchTarget) { - languageServer.openSolution(vscode.Uri.file(launchTarget.target)); + const uri = vscode.Uri.file(launchTarget.target); + languageServer.openSolution(uri); + return uri; } } diff --git a/src/lsptoolshost/roslynLanguageServer.ts b/src/lsptoolshost/roslynLanguageServer.ts index 7baf02093..a2d59c1ab 100644 --- a/src/lsptoolshost/roslynLanguageServer.ts +++ b/src/lsptoolshost/roslynLanguageServer.ts @@ -425,6 +425,32 @@ export class RoslynLanguageServer { if (solutionUris) { if (solutionUris.length === 1) { this.openSolution(solutionUris[0]); + } else if (solutionUris.length > 1) { + // We have more than one solution, so we'll prompt the user to use the picker. + const chosen = await vscode.window.showInformationMessage( + vscode.l10n.t( + 'Your workspace has multiple Visual Studio Solution files; please select one to get full IntelliSense.' + ), + { title: vscode.l10n.t('Choose'), action: 'open' }, + { title: vscode.l10n.t('Choose and set default'), action: 'openAndSetDefault' }, + { title: vscode.l10n.t('Do not load any'), action: 'disable' } + ); + + if (chosen) { + if (chosen.action === 'disable') { + vscode.workspace.getConfiguration().update('dotnet.defaultSolution', 'disable', false); + } else { + const chosenSolution: vscode.Uri | undefined = await vscode.commands.executeCommand( + 'dotnet.openSolution' + ); + if (chosen.action === 'openAndSetDefault' && chosenSolution) { + const relativePath = vscode.workspace.asRelativePath(chosenSolution); + vscode.workspace + .getConfiguration() + .update('dotnet.defaultSolution', relativePath, false); + } + } + } } else if (solutionUris.length === 0) { // We have no solutions, so we'll enumerate what project files we have and just use those. const projectUris = await vscode.workspace.findFiles(