Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Delay diagnostics to give priority to other client requests #345

Merged
merged 3 commits into from
Sep 8, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/typescript-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ export class TypeScriptService {
// Ensure files needed for most operations are fetched
await this.projectManager.ensureReferencedFiles(uri).toPromise();
this.projectManager.didOpen(uri, params.textDocument.text);
this._publishDiagnostics(uri);
setTimeout(() => this._publishDiagnostics(uri), 200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if publishDiagnostics throws this crashes the process. I would do this:

await new Promise(resolve => setTimeout(resolve, 200))
this._publishDiagnostics(uri)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, all error handling out the window.
Cleaned up the tests after applying your suggestion, thanks for the help!

}

/**
Expand All @@ -1288,7 +1288,7 @@ export class TypeScriptService {
return;
}
this.projectManager.didChange(uri, text);
this._publishDiagnostics(uri);
setTimeout(() => this._publishDiagnostics(uri), 200);
}

/**
Expand Down