Skip to content

Commit 33cd37b

Browse files
Allow saving of the chosen solution
1 parent d547538 commit 33cd37b

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

l10n/bundle.l10n.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@
119119
"Ignore": "Ignore",
120120
"Run and Debug: A valid browser is not installed": "Run and Debug: A valid browser is not installed",
121121
"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 solution": "Choose solution",
123-
"Do not load solutions": "Do not load solutions",
122+
"Choose": "Choose",
123+
"Choose and set default": "Choose and set default",
124+
"Do not load any": "Do not load any",
124125
"Restart Language Server": "Restart Language Server",
125126
"pipeArgs must be a string or a string array type": "pipeArgs must be a string or a string array type",
126127
"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: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,15 +431,24 @@ export class RoslynLanguageServer {
431431
vscode.l10n.t(
432432
'Your workspace has multiple Visual Studio Solution files; please select one to get full IntelliSense.'
433433
),
434-
{ title: vscode.l10n.t('Choose solution'), open: true },
435-
{ title: vscode.l10n.t('Do not load solutions'), open: false }
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' }
436437
);
437438

438439
if (chosen) {
439-
if (chosen.open) {
440-
vscode.commands.executeCommand('dotnet.openSolution');
441-
} else {
440+
if (chosen.action === 'disable') {
442441
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+
}
443452
}
444453
}
445454
} else if (solutionUris.length === 0) {

0 commit comments

Comments
 (0)