From ee8ec91efd803172d930a3ead099aa66cc20b983 Mon Sep 17 00:00:00 2001 From: Dirk Baeumer Date: Fri, 26 Aug 2016 16:31:40 +0200 Subject: [PATCH] Fixes #8081: "Open Symbol By Name" is not working properly in multipy typescript projects. --- .../src/features/workspaceSymbolProvider.ts | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/extensions/typescript/src/features/workspaceSymbolProvider.ts b/extensions/typescript/src/features/workspaceSymbolProvider.ts index 5b8dd5057da..1fced2f10fb 100644 --- a/extensions/typescript/src/features/workspaceSymbolProvider.ts +++ b/extensions/typescript/src/features/workspaceSymbolProvider.ts @@ -5,7 +5,7 @@ 'use strict'; -import { workspace, Uri, WorkspaceSymbolProvider, SymbolInformation, SymbolKind, Range, Location, CancellationToken } from 'vscode'; +import { workspace, window, Uri, WorkspaceSymbolProvider, SymbolInformation, SymbolKind, Range, Location, CancellationToken } from 'vscode'; import * as Proto from '../protocol'; import { ITypescriptServiceClient } from '../typescriptService'; @@ -30,14 +30,23 @@ export default class TypeScriptWorkspaceSymbolProvider implements WorkspaceSymbo public provideWorkspaceSymbols(search: string, token :CancellationToken): Promise { // typescript wants to have a resource even when asking - // general questions so we check all open documents for - // one that is typescript'ish + // general questions so we check the active editor. If this + // doesn't match we take the first TS document. let uri: Uri; - let documents = workspace.textDocuments; - for (let document of documents) { - if (document.languageId === this.modeId) { + let editor = window.activeTextEditor; + if (editor) { + let document = editor.document; + if (document && document.languageId === this.modeId) { uri = document.uri; - break; + } + } + if (!uri) { + let documents = workspace.textDocuments; + for (let document of documents) { + if (document.languageId === this.modeId) { + uri = document.uri; + break; + } } }