Skip to content

Commit 81213cb

Browse files
Update support for dotnet.defaultSolution to recognize 'disable'
1 parent 92b69ec commit 81213cb

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,13 @@ export class RoslynLanguageServer {
222222
// Register Razor dynamic file info handling
223223
this.registerRazor(this._languageClient);
224224

225-
// If Dev Kit isn't installed, then we are responsible for picking the solution to open. Check the workpace setting,
226-
// or fallback to looking for a solution
227-
if (!this._wasActivatedWithCSharpDevkit) {
228-
if (this._solutionFile === undefined && options.commonOptions.defaultSolution !== '') {
225+
// If Dev Kit isn't installed, then we are responsible for picking the solution to open, assuming the user hasn't explicitly
226+
// disabled it.
227+
if (!this._wasActivatedWithCSharpDevkit && options.commonOptions.defaultSolution !== 'disable' && this._solutionFile === undefined) {
228+
if (options.commonOptions.defaultSolution !== '') {
229229
this.openSolution(vscode.Uri.file(options.commonOptions.defaultSolution));
230230
} else {
231-
// Auto open if there is just one solution target, if not the let the user trigger an open solution themselves
231+
// Auto open if there is just one solution target; if there's more the one we'll just let the user pick with the picker.
232232
const solutionUris = await vscode.workspace.findFiles('**/*.sln', '**/node_modules/**', 2);
233233
if (solutionUris && solutionUris.length === 1) {
234234
this.openSolution(solutionUris[0]);

src/shared/options.ts

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,31 @@ export class Options {
3838

3939
let defaultSolution = '';
4040

41-
if (vscode.workspace.workspaceFolders !== undefined) {
42-
// If this is multi-folder, then check to see if we have a fully qualified path set directly in the workspace settings; this will let the user directly specify in their
43-
// workspace settings which one is active in the case of a multi-folder workspace. This has to be absolute because in this case, there's no clear folder to resolve a relative
44-
// path against.
45-
if (vscode.workspace.workspaceFolders.length > 1) {
46-
const defaultSolutionFromWorkspace = Options.readOption<string>(config, 'dotnet.defaultSolution', '', 'omnisharp.defaultLaunchSolution');
47-
if (path.isAbsolute(defaultSolutionFromWorkspace)) {
48-
defaultSolution = defaultSolutionFromWorkspace;
41+
const defaultSolutionFromWorkspace = Options.readOption<string>(config, 'dotnet.defaultSolution', '', 'omnisharp.defaultLaunchSolution');
42+
43+
// If the workspace has defaultSolution disabled, just be done
44+
if (defaultSolutionFromWorkspace === "disable") {
45+
defaultSolution = "disable";
46+
} else {
47+
if (vscode.workspace.workspaceFolders !== undefined) {
48+
// If this is multi-folder, then check to see if we have a fully qualified path set directly in the workspace settings; this will let the user directly specify in their
49+
// workspace settings which one is active in the case of a multi-folder workspace. This has to be absolute because in this case, there's no clear folder to resolve a relative
50+
// path against.
51+
if (vscode.workspace.workspaceFolders.length > 1) {
52+
if (path.isAbsolute(defaultSolutionFromWorkspace)) {
53+
defaultSolution = defaultSolutionFromWorkspace;
54+
}
4955
}
50-
}
5156

52-
// If we didn't have an absolute workspace setting, then check each workspace folder and resolve any relative paths against it
53-
if(defaultSolution == '') {
54-
for (let workspaceFolder of vscode.workspace.workspaceFolders) {
55-
const workspaceFolderConfig = vscode.workspace.getConfiguration(undefined, workspaceFolder.uri);
56-
const defaultSolutionFromWorkspaceFolder = Options.readOption<string>(workspaceFolderConfig, 'dotnet.defaultSolution', '', 'omnisharp.defaultLaunchSolution');
57-
if (defaultSolutionFromWorkspaceFolder !== '') {
58-
defaultSolution = path.join(workspaceFolder.uri.fsPath, defaultSolutionFromWorkspaceFolder);
59-
break;
57+
// If we didn't have an absolute workspace setting, then check each workspace folder and resolve any relative paths against it
58+
if(defaultSolution == '') {
59+
for (let workspaceFolder of vscode.workspace.workspaceFolders) {
60+
const workspaceFolderConfig = vscode.workspace.getConfiguration(undefined, workspaceFolder.uri);
61+
const defaultSolutionFromWorkspaceFolder = Options.readOption<string>(workspaceFolderConfig, 'dotnet.defaultSolution', '', 'omnisharp.defaultLaunchSolution');
62+
if (defaultSolutionFromWorkspaceFolder !== '' && defaultSolutionFromWorkspaceFolder !== "disable") {
63+
defaultSolution = path.join(workspaceFolder.uri.fsPath, defaultSolutionFromWorkspaceFolder);
64+
break;
65+
}
6066
}
6167
}
6268
}
@@ -251,7 +257,7 @@ export interface CommonOptions {
251257
useOmnisharpServer: boolean;
252258
excludePaths: string[];
253259

254-
/** The default solution; this has been normalized to a full file path from the workspace folder it was configured in */
260+
/** The default solution; this has been normalized to a full file path from the workspace folder it was configured in, or the string "disable" if that has been disabled */
255261
defaultSolution: string;
256262
}
257263

0 commit comments

Comments
 (0)