Skip to content

Commit e02b0a3

Browse files
fearthecowboysean-mcmanus
authored andcommitted
Enqueue the call to sendDidOpen (#11337)
* enqueue the call to sendDidOpen
1 parent 47785c4 commit e02b0a3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Extension/src/LanguageServer/client.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,9 @@ export class DefaultClient implements Client {
13171317
if (!languageClient || languageClientCrashedNeedsRestart) {
13181318
if (languageClientCrashedNeedsRestart) {
13191319
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();
13201323
}
13211324
firstClientStarted = this.createLanguageClient();
13221325
util.setProgress(util.getProgressExecutableStarted());
@@ -2193,7 +2196,9 @@ export class DefaultClient implements Client {
21932196
public async takeOwnership(document: vscode.TextDocument): Promise<void> {
21942197
this.trackedDocuments.add(document);
21952198
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);
21972202
}
21982203

21992204
public async sendDidOpen(document: vscode.TextDocument): Promise<void> {
@@ -2264,13 +2269,13 @@ export class DefaultClient implements Client {
22642269
* order they were inserted.
22652270
*/
22662271
private static async dispatch() {
2267-
// ensure that this is OK to start working
2268-
await this.isStarted;
2269-
22702272
// reset the promise for the dispatcher
22712273
DefaultClient.dispatching.reset();
22722274

22732275
do {
2276+
// ensure that this is OK to start working
2277+
await this.isStarted;
2278+
22742279
// pick items up off the queue and run then one at a time until the queue is empty
22752280
const [promise, task] = DefaultClient.queue.shift() ?? [];
22762281
if (promise) {

0 commit comments

Comments
 (0)