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
This commit is contained in:
Andrew Casey 2020-02-20 17:30:50 -08:00 committed by GitHub
parent d0c961e544
commit cf24c4fdc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 1 deletions

View File

@ -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 &&

View File

@ -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<protocol.NavtoRequestArgs>(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);
});
});
}