fix54492: allow editor to check for original file extension for rename (#56680)

This commit is contained in:
Isabel Duan
2023-12-08 09:32:52 -08:00
committed by GitHub
parent e3d234cfc8
commit 8dfbfcb058
9 changed files with 236 additions and 9 deletions
@@ -193,4 +193,23 @@ describe("unittests:: tsserver:: rename", () => {
});
baselineTsserverLogs("rename", "with symlinks and case difference", session);
});
it("rename TS file with js extension", () => {
const aTs: File = { path: "/a.ts", content: "export const a = 1;" };
const bTs: File = { path: "/b.ts", content: `import * as foo from './a.js';` };
const host = createServerHost([aTs, bTs]);
const session = new TestSession(host);
openFilesForSession([aTs, bTs], session);
session.executeCommandSeq<ts.server.protocol.ConfigureRequest>({
command: ts.server.protocol.CommandTypes.Configure,
arguments: { preferences: { allowRenameOfImportPath: true } },
});
session.executeCommandSeq<ts.server.protocol.RenameRequest>({
command: ts.server.protocol.CommandTypes.Rename,
arguments: protocolFileLocationFromSubstring(bTs, "a.js"),
});
baselineTsserverLogs("rename", "rename TS file with js extension", session);
});
});