@@ -150,9 +150,10 @@ export class RoslynLanguageServer {
150
150
}
151
151
152
152
/**
153
- * Resolves server options and starts the dotnet language server process.
153
+ * Resolves server options and starts the dotnet language server process. The process is started asynchronously and this method will not wait until
154
+ * the process is launched.
154
155
*/
155
- public async start ( ) : Promise < void > {
156
+ public start ( ) : void {
156
157
let options = this . optionProvider . GetLatestOptions ( ) ;
157
158
let logLevel = options . languageServerOptions . logLevel ;
158
159
const languageClientTraceLevel = this . GetTraceLevel ( logLevel ) ;
@@ -207,7 +208,11 @@ export class RoslynLanguageServer {
207
208
this . _languageClient . onDidChangeState ( async ( state ) => {
208
209
if ( state . newState === State . Running ) {
209
210
await this . _languageClient ! . setTrace ( languageClientTraceLevel ) ;
210
- await this . sendOpenSolutionNotification ( ) ;
211
+ if ( this . _solutionFile ) {
212
+ await this . sendOpenSolutionNotification ( ) ;
213
+ } else {
214
+ await this . openDefaultSolution ( ) ;
215
+ }
211
216
await this . sendOrSubscribeForServiceBrokerConnection ( ) ;
212
217
this . _eventBus . emit ( RoslynLanguageServer . serverStateChangeEvent , ServerStateChange . Started ) ;
213
218
}
@@ -222,20 +227,6 @@ export class RoslynLanguageServer {
222
227
223
228
// Register Razor dynamic file info handling
224
229
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
- }
239
230
}
240
231
241
232
public async stop ( ) : Promise < void > {
@@ -245,13 +236,13 @@ export class RoslynLanguageServer {
245
236
}
246
237
247
238
/**
248
- * Restarts the language server.
239
+ * Restarts the language server. This does not wait until the server has been restarted.
249
240
* Note that since some options affect how the language server is initialized, we must
250
- * re-create the LanguageClient instance instead of just stopping/starting it.
241
+ * re-create the LanguageClient instance instead of just stopping/starting it.
251
242
*/
252
243
public async restart ( ) : Promise < void > {
253
244
await this . stop ( ) ;
254
- await this . start ( ) ;
245
+ this . start ( ) ;
255
246
}
256
247
257
248
/**
@@ -309,14 +300,32 @@ export class RoslynLanguageServer {
309
300
await this . sendOpenSolutionNotification ( ) ;
310
301
}
311
302
312
- private async sendOpenSolutionNotification ( ) {
303
+ private async sendOpenSolutionNotification ( ) : Promise < void > {
313
304
if ( this . _solutionFile !== undefined && this . _languageClient !== undefined && this . _languageClient . isRunning ( ) ) {
314
305
let protocolUri = this . _languageClient . clientOptions . uriConverters ! . code2Protocol ( this . _solutionFile ) ;
315
306
await this . _languageClient . sendNotification ( "solution/open" , new OpenSolutionParams ( protocolUri ) ) ;
316
307
}
317
308
}
318
309
319
- private async sendOrSubscribeForServiceBrokerConnection ( ) {
310
+ private async openDefaultSolution ( ) : Promise < void > {
311
+ const options = this . optionProvider . GetLatestOptions ( ) ;
312
+
313
+ // If Dev Kit isn't installed, then we are responsible for picking the solution to open, assuming the user hasn't explicitly
314
+ // disabled it.
315
+ if ( ! this . _wasActivatedWithCSharpDevkit && options . commonOptions . defaultSolution !== 'disable' && this . _solutionFile === undefined ) {
316
+ if ( options . commonOptions . defaultSolution !== '' ) {
317
+ this . openSolution ( vscode . Uri . file ( options . commonOptions . defaultSolution ) ) ;
318
+ } else {
319
+ // 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.
320
+ const solutionUris = await vscode . workspace . findFiles ( '**/*.sln' , '**/node_modules/**' , 2 ) ;
321
+ if ( solutionUris && solutionUris . length === 1 ) {
322
+ this . openSolution ( solutionUris [ 0 ] ) ;
323
+ }
324
+ }
325
+ }
326
+ }
327
+
328
+ private async sendOrSubscribeForServiceBrokerConnection ( ) : Promise < void > {
320
329
const csharpDevKitExtension = vscode . extensions . getExtension < CSharpDevKitExports > ( csharpDevkitExtensionId ) ;
321
330
if ( csharpDevKitExtension ) {
322
331
const exports = await csharpDevKitExtension . activate ( ) ;
@@ -627,7 +636,7 @@ export async function activateRoslynLanguageServer(context: vscode.ExtensionCont
627
636
} ) ;
628
637
629
638
// Start the language server.
630
- await _languageServer . start ( ) ;
639
+ _languageServer . start ( ) ;
631
640
}
632
641
633
642
async function applyAutoInsertEdit ( e : vscode . TextDocumentChangeEvent , token : vscode . CancellationToken ) {
0 commit comments