Skip to content

Commit 30bd841

Browse files
committed
Merge branch 'master' into tsconfigMixedContentSupport
2 parents 05160ca + 798d080 commit 30bd841

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

src/harness/unittests/textStorage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ namespace ts.textStorage {
1616

1717
it("text based storage should be have exactly the same as script version cache", () => {
1818

19-
debugger
2019
const host = ts.projectSystem.createServerHost([f]);
2120

2221
const ts1 = new server.TextStorage(host, server.asNormalizedPath(f.path));

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ namespace ts.projectSystem {
140140
export interface TestServerHostCreationParameters {
141141
useCaseSensitiveFileNames?: boolean;
142142
executingFilePath?: string;
143-
libFile?: FileOrFolder;
144143
currentDirectory?: string;
145144
}
146145

@@ -1145,6 +1144,69 @@ namespace ts.projectSystem {
11451144
checkNumberOfProjects(projectService, {});
11461145
});
11471146

1147+
it("reload regular file after closing", () => {
1148+
const f1 = {
1149+
path: "/a/b/app.ts",
1150+
content: "x."
1151+
};
1152+
const f2 = {
1153+
path: "/a/b/lib.ts",
1154+
content: "let x: number;"
1155+
};
1156+
1157+
const host = createServerHost([f1, f2, libFile]);
1158+
const service = createProjectService(host);
1159+
service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: toExternalFiles([f1.path, f2.path]), options: {} })
1160+
1161+
service.openClientFile(f1.path);
1162+
service.openClientFile(f2.path, "let x: string");
1163+
1164+
service.checkNumberOfProjects({ externalProjects: 1 });
1165+
checkProjectActualFiles(service.externalProjects[0], [f1.path, f2.path, libFile.path]);
1166+
1167+
const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2);
1168+
// should contain completions for string
1169+
assert.isTrue(completions1.entries.some(e => e.name === "charAt"), "should contain 'charAt'");
1170+
assert.isFalse(completions1.entries.some(e => e.name === "toExponential"), "should not contain 'toExponential'");
1171+
1172+
service.closeClientFile(f2.path);
1173+
const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2);
1174+
// should contain completions for string
1175+
assert.isFalse(completions2.entries.some(e => e.name === "charAt"), "should not contain 'charAt'");
1176+
assert.isTrue(completions2.entries.some(e => e.name === "toExponential"), "should contain 'toExponential'");
1177+
});
1178+
1179+
it("clear mixed content file after closing", () => {
1180+
const f1 = {
1181+
path: "/a/b/app.ts",
1182+
content: " "
1183+
};
1184+
const f2 = {
1185+
path: "/a/b/lib.html",
1186+
content: "<html/>"
1187+
};
1188+
1189+
const host = createServerHost([f1, f2, libFile]);
1190+
const service = createProjectService(host);
1191+
service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: [{ fileName: f1.path }, { fileName: f2.path, hasMixedContent: true }], options: {} })
1192+
1193+
service.openClientFile(f1.path);
1194+
service.openClientFile(f2.path, "let somelongname: string");
1195+
1196+
service.checkNumberOfProjects({ externalProjects: 1 });
1197+
checkProjectActualFiles(service.externalProjects[0], [f1.path, f2.path, libFile.path]);
1198+
1199+
const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 0);
1200+
assert.isTrue(completions1.entries.some(e => e.name === "somelongname"), "should contain 'somelongname'");
1201+
1202+
service.closeClientFile(f2.path);
1203+
const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 0);
1204+
assert.isFalse(completions2.entries.some(e => e.name === "somelongname"), "should not contain 'somelongname'");
1205+
const sf2 = service.externalProjects[0].getLanguageService().getProgram().getSourceFile(f2.path);
1206+
assert.equal(sf2.text, "");
1207+
});
1208+
1209+
11481210
it("external project with included config file opened after configured project", () => {
11491211
const file1 = {
11501212
path: "/a/b/f1.ts",

0 commit comments

Comments
 (0)