Skip to content

Commit 29620d9

Browse files
Merge pull request #6132 from jasonmalinowski/make-multiple-solutions-friendlier
Show a prompt if we have more than one solution file
2 parents 4e96385 + 33cd37b commit 29620d9

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

l10n/bundle.l10n.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@
118118
"View Debug Docs": "View Debug Docs",
119119
"Ignore": "Ignore",
120120
"Run and Debug: A valid browser is not installed": "Run and Debug: A valid browser is not installed",
121+
"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.",
122+
"Choose": "Choose",
123+
"Choose and set default": "Choose and set default",
124+
"Do not load any": "Do not load any",
121125
"Restart Language Server": "Restart Language Server",
122126
"pipeArgs must be a string or a string array type": "pipeArgs must be a string or a string array type",
123127
"Name not defined in current configuration.": "Name not defined in current configuration.",

src/lsptoolshost/commands.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ async function completionComplexEdit(
146146
}
147147
}
148148

149-
async function openSolution(languageServer: RoslynLanguageServer): Promise<void> {
149+
async function openSolution(languageServer: RoslynLanguageServer): Promise<vscode.Uri | undefined> {
150150
if (!vscode.workspace.workspaceFolders) {
151-
return;
151+
return undefined;
152152
}
153153

154154
const solutionFiles = await vscode.workspace.findFiles('**/*.sln');
@@ -159,6 +159,8 @@ async function openSolution(languageServer: RoslynLanguageServer): Promise<void>
159159
});
160160

161161
if (launchTarget) {
162-
languageServer.openSolution(vscode.Uri.file(launchTarget.target));
162+
const uri = vscode.Uri.file(launchTarget.target);
163+
languageServer.openSolution(uri);
164+
return uri;
163165
}
164166
}

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,32 @@ export class RoslynLanguageServer {
425425
if (solutionUris) {
426426
if (solutionUris.length === 1) {
427427
this.openSolution(solutionUris[0]);
428+
} else if (solutionUris.length > 1) {
429+
// We have more than one solution, so we'll prompt the user to use the picker.
430+
const chosen = await vscode.window.showInformationMessage(
431+
vscode.l10n.t(
432+
'Your workspace has multiple Visual Studio Solution files; please select one to get full IntelliSense.'
433+
),
434+
{ title: vscode.l10n.t('Choose'), action: 'open' },
435+
{ title: vscode.l10n.t('Choose and set default'), action: 'openAndSetDefault' },
436+
{ title: vscode.l10n.t('Do not load any'), action: 'disable' }
437+
);
438+
439+
if (chosen) {
440+
if (chosen.action === 'disable') {
441+
vscode.workspace.getConfiguration().update('dotnet.defaultSolution', 'disable', false);
442+
} else {
443+
const chosenSolution: vscode.Uri | undefined = await vscode.commands.executeCommand(
444+
'dotnet.openSolution'
445+
);
446+
if (chosen.action === 'openAndSetDefault' && chosenSolution) {
447+
const relativePath = vscode.workspace.asRelativePath(chosenSolution);
448+
vscode.workspace
449+
.getConfiguration()
450+
.update('dotnet.defaultSolution', relativePath, false);
451+
}
452+
}
453+
}
428454
} else if (solutionUris.length === 0) {
429455
// We have no solutions, so we'll enumerate what project files we have and just use those.
430456
const projectUris = await vscode.workspace.findFiles(

0 commit comments

Comments
 (0)