Skip to content

Commit 2bf39a6

Browse files
author
Zhengbo Li
committed
Merge pull request microsoft#5261 from zhengbli/i5015
Re-read file content upon closing
2 parents 21e30e0 + f91bee0 commit 2bf39a6

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/server/editorServices.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,11 @@ namespace ts.server {
683683
* @param info The file that has been closed or newly configured
684684
*/
685685
closeOpenFile(info: ScriptInfo) {
686+
// Closing file should trigger re-reading the file content from disk. This is
687+
// because the user may chose to discard the buffer content before saving
688+
// to the disk, and the server's version of the file can be out of sync.
689+
info.svc.reloadFromFile(info.fileName);
690+
686691
var openFileRoots: ScriptInfo[] = [];
687692
var removedProject: Project;
688693
for (var i = 0, len = this.openFileRoots.length; i < len; i++) {

0 commit comments

Comments
 (0)