Don't register a new TypeScriptWorkspaceSymbolProvider for each mode, only for each language

This commit is contained in:
Matt Bierner
2017-11-07 16:48:38 -08:00
parent 888431fce3
commit d319d356bd
2 changed files with 7 additions and 6 deletions

View File

@@ -24,7 +24,8 @@ function getSymbolKind(item: Proto.NavtoItem): SymbolKind {
export default class TypeScriptWorkspaceSymbolProvider implements WorkspaceSymbolProvider {
public constructor(
private client: ITypeScriptServiceClient,
private modeId: string) { }
private modeIds: string[]
) { }
public async provideWorkspaceSymbols(search: string, token: CancellationToken): Promise<SymbolInformation[]> {
// typescript wants to have a resource even when asking
@@ -34,14 +35,14 @@ export default class TypeScriptWorkspaceSymbolProvider implements WorkspaceSymbo
const editor = window.activeTextEditor;
if (editor) {
const document = editor.document;
if (document && document.languageId === this.modeId) {
if (document && this.modeIds.indexOf(document.languageId) >= 0) {
uri = document.uri;
}
}
if (!uri) {
const documents = workspace.textDocuments;
for (const document of documents) {
if (document.languageId === this.modeId) {
if (this.modeIds.indexOf(document.languageId) >= 0) {
uri = document.uri;
break;
}

View File

@@ -334,10 +334,10 @@ class LanguageProvider {
this.toUpdateOnConfigurationChanged.push(implementationCodeLensProvider);
this.disposables.push(languages.registerCodeLensProvider(selector, implementationCodeLensProvider));
for (const modeId of this.description.modeIds) {
this.disposables.push(languages.registerWorkspaceSymbolProvider(new (await import('./features/workspaceSymbolProvider')).default(client, modeId)));
this.disposables.push(languages.registerWorkspaceSymbolProvider(new (await import('./features/workspaceSymbolProvider')).default(client, this.description.modeIds)));
if (!this.description.isExternal) {
if (!this.description.isExternal) {
for (const modeId of this.description.modeIds) {
this.disposables.push(languages.setLanguageConfiguration(modeId, {
indentationRules: {
// ^(.*\*/)?\s*\}.*$