Skip to content

Commit e769a76

Browse files
andrius-praKeen Yee Liau
authored andcommitted
fix: avoid close project while saving file
1 parent 08415b4 commit e769a76

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

server/src/documents.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ export class TextDocuments {
211211
this.changeNumber++;
212212
const file = uriToFileName(event.textDocument.uri);
213213
if (file) {
214-
const savedContent = this.host.readFile(file);
215-
this.projectService.closeClientFile(file);
216-
this.projectService.openClientFile(file, savedContent);
214+
this.projectService.reloadScript(file);
217215
this.changeNumber++;
218216
}
219217
}));

server/src/editorServices.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,15 @@ export class ProjectService {
16411641
this.report("change", file, project);
16421642
}
16431643

1644+
reloadScript(filename: string): void {
1645+
const info: ScriptInfo = this.filenameToScriptInfo[filename];
1646+
if (info) {
1647+
info.svc.reloadFromFile(filename);
1648+
this.changeSeq++;
1649+
this.report("change", info.fileName)
1650+
}
1651+
}
1652+
16441653
forcedGetProjectForFile(fileName: string): Project {
16451654
const file = normalizePath(fileName);
16461655
const info = this.filenameToScriptInfo[file];

0 commit comments

Comments
 (0)