Skip to content

Commit 23915af

Browse files
authored
Exclude chat symbols from JS/TS workspace symbol results (microsoft#210095)
1 parent 0e263c4 commit 23915af

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

extensions/typescript-language-features/src/languageFeatures/workspaceSymbols.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type * as Proto from '../tsServer/protocol/protocol';
1212
import * as PConst from '../tsServer/protocol/protocol.const';
1313
import * as typeConverters from '../typeConverters';
1414
import { ITypeScriptServiceClient } from '../typescriptService';
15+
import { coalesce } from '../utils/arrays';
1516

1617
function getSymbolKind(item: Proto.NavtoItem): vscode.SymbolKind {
1718
switch (item.kind) {
@@ -64,9 +65,7 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide
6465
return [];
6566
}
6667

67-
return response.body
68-
.filter(item => item.containerName || item.kind !== 'alias')
69-
.map(item => this.toSymbolInformation(item));
68+
return coalesce(response.body.map(item => this.toSymbolInformation(item)));
7069
}
7170

7271
private get searchAllOpenProjects() {
@@ -89,13 +88,22 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide
8988
return this.client.toOpenTsFilePath(document);
9089
}
9190

92-
private toSymbolInformation(item: Proto.NavtoItem) {
91+
private toSymbolInformation(item: Proto.NavtoItem): vscode.SymbolInformation | undefined {
92+
if (!item.containerName || item.kind === 'alias') {
93+
return;
94+
}
95+
96+
const uri = this.client.toResource(item.file);
97+
if (uri.scheme === fileSchemes.chatCodeBlock) {
98+
return;
99+
}
100+
93101
const label = TypeScriptWorkspaceSymbolProvider.getLabel(item);
94102
const info = new vscode.SymbolInformation(
95103
label,
96104
getSymbolKind(item),
97105
item.containerName || '',
98-
typeConverters.Location.fromTextSpan(this.client.toResource(item.file), item));
106+
typeConverters.Location.fromTextSpan(uri, item));
99107
const kindModifiers = item.kindModifiers ? parseKindModifier(item.kindModifiers) : undefined;
100108
if (kindModifiers?.has(PConst.KindModifiers.deprecated)) {
101109
info.tags = [vscode.SymbolTag.Deprecated];

0 commit comments

Comments
 (0)