Skip to content

Commit ab5a705

Browse files
Ensure we don't run both project systems at once
When we were looking to see if Dev Kit was installed to know whether we should trigger our own project system, we checked _wasActivatedWithCSharpDevkit; but that wasn't set since we don't await the server launch a few lines before. The field would be unset and as a result we'd run both. Fixes microsoft/vscode-dotnettools#40 Fixes dotnet/roslyn#68472 Fixes #5711
1 parent b1636bf commit ab5a705

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ export class RoslynLanguageServer {
207207
this._languageClient.onDidChangeState(async (state) => {
208208
if (state.newState === State.Running) {
209209
await this._languageClient!.setTrace(languageClientTraceLevel);
210-
await this.sendOpenSolutionNotification();
210+
if (this._solutionFile) {
211+
await this.sendOpenSolutionNotification();
212+
} else {
213+
await this.openDefaultSolution();
214+
}
211215
await this.sendOrSubscribeForServiceBrokerConnection();
212216
this._eventBus.emit(RoslynLanguageServer.serverStateChangeEvent, ServerStateChange.Started);
213217
}
@@ -222,20 +226,6 @@ export class RoslynLanguageServer {
222226

223227
// Register Razor dynamic file info handling
224228
this.registerRazor(this._languageClient);
225-
226-
// If Dev Kit isn't installed, then we are responsible for picking the solution to open, assuming the user hasn't explicitly
227-
// disabled it.
228-
if (!this._wasActivatedWithCSharpDevkit && options.commonOptions.defaultSolution !== 'disable' && this._solutionFile === undefined) {
229-
if (options.commonOptions.defaultSolution !== '') {
230-
this.openSolution(vscode.Uri.file(options.commonOptions.defaultSolution));
231-
} else {
232-
// 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.
233-
const solutionUris = await vscode.workspace.findFiles('**/*.sln', '**/node_modules/**', 2);
234-
if (solutionUris && solutionUris.length === 1) {
235-
this.openSolution(solutionUris[0]);
236-
}
237-
}
238-
}
239229
}
240230

241231
public async stop(): Promise<void> {
@@ -316,6 +306,24 @@ export class RoslynLanguageServer {
316306
}
317307
}
318308

309+
private async openDefaultSolution() {
310+
const options = this.optionProvider.GetLatestOptions();
311+
312+
// If Dev Kit isn't installed, then we are responsible for picking the solution to open, assuming the user hasn't explicitly
313+
// disabled it.
314+
if (!this._wasActivatedWithCSharpDevkit && options.commonOptions.defaultSolution !== 'disable' && this._solutionFile === undefined) {
315+
if (options.commonOptions.defaultSolution !== '') {
316+
this.openSolution(vscode.Uri.file(options.commonOptions.defaultSolution));
317+
} else {
318+
// 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.
319+
const solutionUris = await vscode.workspace.findFiles('**/*.sln', '**/node_modules/**', 2);
320+
if (solutionUris && solutionUris.length === 1) {
321+
this.openSolution(solutionUris[0]);
322+
}
323+
}
324+
}
325+
}
326+
319327
private async sendOrSubscribeForServiceBrokerConnection() {
320328
const csharpDevKitExtension = vscode.extensions.getExtension<CSharpDevKitExports>(csharpDevkitExtensionId);
321329
if (csharpDevKitExtension) {

0 commit comments

Comments
 (0)