From 7ff5164e7bbb5c32a7405bc281b02af6c6e69197 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 20 Feb 2020 14:46:13 -0800 Subject: [PATCH 1/2] Fix copy-paste error in navigateToItemIsEqualTo It was preventing de-duping of items found in multiple projects. --- src/server/session.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/session.ts b/src/server/session.ts index b5487bb7bdf4e..9df1bb1b41a48 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1892,7 +1892,7 @@ namespace ts.server { a.fileName === b.fileName && a.isCaseSensitive === b.isCaseSensitive && a.kind === b.kind && - a.kindModifiers === b.containerName && + a.kindModifiers === b.kindModifiers && a.matchKind === b.matchKind && a.name === b.name && a.textSpan.start === b.textSpan.start && From a91ee0d8c8095fc111d5b85884a62f53f89f66fb Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 20 Feb 2020 16:36:43 -0800 Subject: [PATCH 2/2] Add de-duping test --- src/testRunner/unittests/tsserver/navTo.ts | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/testRunner/unittests/tsserver/navTo.ts b/src/testRunner/unittests/tsserver/navTo.ts index b3aebef104368..0ce98a076de3f 100644 --- a/src/testRunner/unittests/tsserver/navTo.ts +++ b/src/testRunner/unittests/tsserver/navTo.ts @@ -26,5 +26,46 @@ namespace ts.projectSystem { const items2 = session.executeCommand(localFunctionNavToRequst).response as protocol.NavtoItem[]; assert.isTrue(containsNavToItem(items2, "foo", "function"), `Cannot find function symbol "foo".`); }); + + it("should de-duplicate symbols", () => { + const configFile1: File = { + path: "/a/tsconfig.json", + content: `{ + "compilerOptions": { + "composite": true + } +}` + }; + const file1: File = { + path: "/a/index.ts", + content: "export const abcdef = 1;" + }; + const configFile2: File = { + path: "/b/tsconfig.json", + content: `{ + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "../a" } + ] +}` + }; + const file2: File = { + path: "/b/index.ts", + content: `import a = require("../a"); +export const ghijkl = a.abcdef;` + }; + const host = createServerHost([configFile1, file1, configFile2, file2]); + const session = createSession(host); + openFilesForSession([file1, file2], session); + + const request = makeSessionRequest(CommandNames.Navto, { searchValue: "abcdef", file: file1.path }); + const items = session.executeCommand(request).response as protocol.NavtoItem[]; + assert.strictEqual(items.length, 1); + const item = items[0]; + assert.strictEqual(item.name, "abcdef"); + assert.strictEqual(item.file, file1.path); + }); }); }