Skip to content

Commit 15a4aab

Browse files
authored
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.
1 parent 6e57bce commit 15a4aab

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/language-server/src/plugins/PluginHost.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,18 @@ export class PluginHost implements LSProvider, OnWatchFileChanges {
279279
): Promise<SymbolInformation[]> {
280280
const document = this.getDocument(textDocument.uri);
281281

282+
// VSCode requested document symbols twice for the outline view and the sticky scroll
283+
// Manually delay here and don't use low priority as one of them will return no symbols
284+
await new Promise((resolve) => setTimeout(resolve, 1000));
285+
if (cancellationToken.isCancellationRequested) {
286+
return [];
287+
}
282288
return flatten(
283289
await this.execute<SymbolInformation[]>(
284290
'getDocumentSymbols',
285291
[document, cancellationToken],
286292
ExecuteMode.Collect,
287-
'low'
293+
'high'
288294
)
289295
);
290296
}

0 commit comments

Comments
 (0)