Skip to content

Commit

Permalink
fix: don't debounce document symbol request (#2382)
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
jasonlyu123 committed May 29, 2024
1 parent 6e57bce commit 15a4aab
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/language-server/src/plugins/PluginHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,18 @@ export class PluginHost implements LSProvider, OnWatchFileChanges {
): Promise<SymbolInformation[]> {
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<SymbolInformation[]>(
'getDocumentSymbols',
[document, cancellationToken],
ExecuteMode.Collect,
'low'
'high'
)
);
}
Expand Down

0 comments on commit 15a4aab

Please sign in to comment.