Skip to content

Commit 4d6b53b

Browse files
committed
Add test for scenario when script info being operated is pending on reload but has svc for the previous version
Test for microsoft#20806
1 parent 8e8efaf commit 4d6b53b

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,6 +2978,47 @@ namespace ts.projectSystem {
29782978
checkProjectActualFiles(configuredProject, [file.path, filesFile1.path, libFile.path, config.path]);
29792979
}
29802980
});
2981+
2982+
it("requests are done on file on pendingReload but has svc for previous version", () => {
2983+
const projectLocation = "/user/username/projects/project";
2984+
const file1: FileOrFolder = {
2985+
path: `${projectLocation}/src/file1.ts`,
2986+
content: `import { y } from "./file1"; let x = 10;`
2987+
};
2988+
const file2: FileOrFolder = {
2989+
path: `${projectLocation}/src/file2.ts`,
2990+
content: "export let y = 10;"
2991+
};
2992+
const config: FileOrFolder = {
2993+
path: `${projectLocation}/tsconfig.json`,
2994+
content: "{}"
2995+
};
2996+
const files = [file1, file2, libFile, config];
2997+
const host = createServerHost(files);
2998+
const session = createSession(host);
2999+
session.executeCommandSeq<protocol.OpenRequest>({
3000+
command: protocol.CommandTypes.Open,
3001+
arguments: { file: file2.path, fileContent: file2.content }
3002+
});
3003+
session.executeCommandSeq<protocol.OpenRequest>({
3004+
command: protocol.CommandTypes.Open,
3005+
arguments: { file: file1.path }
3006+
});
3007+
session.executeCommandSeq<protocol.CloseRequest>({
3008+
command: protocol.CommandTypes.Close,
3009+
arguments: { file: file2.path }
3010+
});
3011+
3012+
file2.content += "export let z = 10;";
3013+
host.reloadFS(files);
3014+
// Do not let the timeout runs, before executing command
3015+
const startOffset = file2.content.indexOf("y") + 1;
3016+
session.executeCommandSeq<protocol.GetApplicableRefactorsRequest>({
3017+
command: protocol.CommandTypes.GetApplicableRefactors,
3018+
arguments: { file: file2.path, startLine: 1, startOffset, endLine: 1, endOffset: startOffset + 1 }
3019+
});
3020+
3021+
});
29813022
});
29823023

29833024
describe("tsserverProjectSystem Proper errors", () => {

0 commit comments

Comments
 (0)