From 15a4aab0d1e1c36d95d7d81dd3b3f52d95dda837 Mon Sep 17 00:00:00 2001 From: "Lyu, Wei-Da" <36730922+jasonlyu123@users.noreply.github.com> Date: Wed, 29 May 2024 22:47:24 +0800 Subject: [PATCH] fix: don't debounce document symbol request (#2382) #2353 The reason is that VSCode requested document symbols twice for the outline view and the sticky scroll. We cancelled one of them so the outline view shows "no symbols found in document 'A.svelte'". It seems the VSCode ts extension also caches the result from tsserver, mostly because it'll also be used in code lens. But the result is mostly fast enough. A 5000-line file takes like 100ms so we probably don't need it now. We can probably reconsider if #2378 lands and see if there is a large performance regression. --- packages/language-server/src/plugins/PluginHost.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/language-server/src/plugins/PluginHost.ts b/packages/language-server/src/plugins/PluginHost.ts index b239c21ee..b02009acf 100644 --- a/packages/language-server/src/plugins/PluginHost.ts +++ b/packages/language-server/src/plugins/PluginHost.ts @@ -279,12 +279,18 @@ export class PluginHost implements LSProvider, OnWatchFileChanges { ): Promise { const document = this.getDocument(textDocument.uri); + // VSCode requested document symbols twice for the outline view and the sticky scroll + // Manually delay here and don't use low priority as one of them will return no symbols + await new Promise((resolve) => setTimeout(resolve, 1000)); + if (cancellationToken.isCancellationRequested) { + return []; + } return flatten( await this.execute( 'getDocumentSymbols', [document, cancellationToken], ExecuteMode.Collect, - 'low' + 'high' ) ); }