Skip to content

Commit b1557cb

Browse files
committed
Fixes #986: Language client is not ready yet
1 parent b9ec3bb commit b1557cb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

client/src/extension.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,16 +894,18 @@ function realActivate(context: ExtensionContext): void {
894894
const configFileFilter: DocumentFilter = { scheme: 'file', pattern: '**/.eslintr{c.js,c.yaml,c.yml,c,c.json}' };
895895
const syncedDocuments: Map<string, TextDocument> = new Map<string, TextDocument>();
896896

897-
Workspace.onDidChangeConfiguration(() => {
897+
Workspace.onDidChangeConfiguration(async() => {
898898
probeFailed.clear();
899899
for (const textDocument of syncedDocuments.values()) {
900900
if (computeValidate(textDocument) === Validate.off) {
901901
syncedDocuments.delete(textDocument.uri.toString());
902+
await client.onReady();
902903
client.sendNotification(DidCloseTextDocumentNotification.type, client.code2ProtocolConverter.asCloseTextDocumentParams(textDocument));
903904
}
904905
}
905906
for (const textDocument of Workspace.textDocuments) {
906907
if (!syncedDocuments.has(textDocument.uri.toString()) && computeValidate(textDocument) !== Validate.off) {
908+
await client.onReady();
907909
client.sendNotification(DidOpenTextDocumentNotification.type, client.code2ProtocolConverter.asOpenTextDocumentParams(textDocument));
908910
syncedDocuments.set(textDocument.uri.toString(), textDocument);
909911
}
@@ -1350,7 +1352,7 @@ function realActivate(context: ExtensionContext): void {
13501352

13511353
context.subscriptions.push(
13521354
client.start(),
1353-
Commands.registerCommand('eslint.executeAutofix', () => {
1355+
Commands.registerCommand('eslint.executeAutofix', async () => {
13541356
const textEditor = Window.activeTextEditor;
13551357
if (!textEditor) {
13561358
return;
@@ -1363,6 +1365,7 @@ function realActivate(context: ExtensionContext): void {
13631365
command: 'eslint.applyAllFixes',
13641366
arguments: [textDocument]
13651367
};
1368+
await client.onReady();
13661369
client.sendRequest(ExecuteCommandRequest.type, params).then(undefined, () => {
13671370
Window.showErrorMessage('Failed to apply ESLint fixes to the document. Please consider opening an issue with steps to reproduce.');
13681371
});

0 commit comments

Comments
 (0)