@@ -1317,6 +1317,9 @@ export class DefaultClient implements Client {
1317
1317
if ( ! languageClient || languageClientCrashedNeedsRestart ) {
1318
1318
if ( languageClientCrashedNeedsRestart ) {
1319
1319
languageClientCrashedNeedsRestart = false ;
1320
+ // if we're recovering, the isStarted needs to be reset.
1321
+ // because we're starting the first client again.
1322
+ DefaultClient . isStarted . reset ( ) ;
1320
1323
}
1321
1324
firstClientStarted = this . createLanguageClient ( ) ;
1322
1325
util . setProgress ( util . getProgressExecutableStarted ( ) ) ;
@@ -2193,7 +2196,9 @@ export class DefaultClient implements Client {
2193
2196
public async takeOwnership ( document : vscode . TextDocument ) : Promise < void > {
2194
2197
this . trackedDocuments . add ( document ) ;
2195
2198
this . updateActiveDocumentTextOptions ( ) ;
2196
- await this . sendDidOpen ( document ) ;
2199
+ // in case the client is recreated, wait for the isStarted to finish.
2200
+ await DefaultClient . isStarted ;
2201
+ return this . sendDidOpen ( document ) ;
2197
2202
}
2198
2203
2199
2204
public async sendDidOpen ( document : vscode . TextDocument ) : Promise < void > {
@@ -2264,13 +2269,13 @@ export class DefaultClient implements Client {
2264
2269
* order they were inserted.
2265
2270
*/
2266
2271
private static async dispatch ( ) {
2267
- // ensure that this is OK to start working
2268
- await this . isStarted ;
2269
-
2270
2272
// reset the promise for the dispatcher
2271
2273
DefaultClient . dispatching . reset ( ) ;
2272
2274
2273
2275
do {
2276
+ // ensure that this is OK to start working
2277
+ await this . isStarted ;
2278
+
2274
2279
// pick items up off the queue and run then one at a time until the queue is empty
2275
2280
const [ promise , task ] = DefaultClient . queue . shift ( ) ?? [ ] ;
2276
2281
if ( promise ) {
0 commit comments