Skip to content

Commit 8acc885

Browse files
committed
Merge pull request #8371 from zhengbli/fixRenameFileCacheIssue
Wipe out the cached script content if failed to read it
2 parents 798257c + 4d94ae8 commit 8acc885

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/server/editorServices.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,12 @@ namespace ts.server {
16851685
}
16861686

16871687
reloadFromFile(filename: string, cb?: () => any) {
1688-
const content = this.host.readFile(filename);
1688+
let content = this.host.readFile(filename);
1689+
// If the file doesn't exist or cannot be read, we should
1690+
// wipe out its cached content on the server to avoid side effects.
1691+
if (!content) {
1692+
content = "";
1693+
}
16891694
this.reload(content);
16901695
if (cb)
16911696
cb();

0 commit comments

Comments
 (0)