Skip to content

Commit cf24c4f

Browse files
authored
Fix copy-paste error in navigateToItemIsEqualTo (#36912)
* Fix copy-paste error in navigateToItemIsEqualTo It was preventing de-duping of items found in multiple projects. * Add de-duping test
1 parent d0c961e commit cf24c4f

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/server/session.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1892,7 +1892,7 @@ namespace ts.server {
18921892
a.fileName === b.fileName &&
18931893
a.isCaseSensitive === b.isCaseSensitive &&
18941894
a.kind === b.kind &&
1895-
a.kindModifiers === b.containerName &&
1895+
a.kindModifiers === b.kindModifiers &&
18961896
a.matchKind === b.matchKind &&
18971897
a.name === b.name &&
18981898
a.textSpan.start === b.textSpan.start &&

src/testRunner/unittests/tsserver/navTo.ts

+41
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,46 @@ namespace ts.projectSystem {
2626
const items2 = session.executeCommand(localFunctionNavToRequst).response as protocol.NavtoItem[];
2727
assert.isTrue(containsNavToItem(items2, "foo", "function"), `Cannot find function symbol "foo".`);
2828
});
29+
30+
it("should de-duplicate symbols", () => {
31+
const configFile1: File = {
32+
path: "/a/tsconfig.json",
33+
content: `{
34+
"compilerOptions": {
35+
"composite": true
36+
}
37+
}`
38+
};
39+
const file1: File = {
40+
path: "/a/index.ts",
41+
content: "export const abcdef = 1;"
42+
};
43+
const configFile2: File = {
44+
path: "/b/tsconfig.json",
45+
content: `{
46+
"compilerOptions": {
47+
"composite": true
48+
},
49+
"references": [
50+
{ "path": "../a" }
51+
]
52+
}`
53+
};
54+
const file2: File = {
55+
path: "/b/index.ts",
56+
content: `import a = require("../a");
57+
export const ghijkl = a.abcdef;`
58+
};
59+
const host = createServerHost([configFile1, file1, configFile2, file2]);
60+
const session = createSession(host);
61+
openFilesForSession([file1, file2], session);
62+
63+
const request = makeSessionRequest<protocol.NavtoRequestArgs>(CommandNames.Navto, { searchValue: "abcdef", file: file1.path });
64+
const items = session.executeCommand(request).response as protocol.NavtoItem[];
65+
assert.strictEqual(items.length, 1);
66+
const item = items[0];
67+
assert.strictEqual(item.name, "abcdef");
68+
assert.strictEqual(item.file, file1.path);
69+
});
2970
});
3071
}

0 commit comments

Comments
 (0)