@@ -54,21 +54,23 @@ function forwardFileChanges(server: OmniSharpServer): IDisposable {
5454 return ;
5555 }
5656
57- const docs = workspace . textDocuments . filter ( doc => doc . uri . fsPath === uri . fsPath ) ;
58- if ( Array . isArray ( docs ) && docs . some ( doc => ! doc . isClosed ) ) {
59- // When a file changes on disk a FileSystemEvent is generated as well as a
60- // DidChangeTextDocumentEvent.The ordering of these is:
61- // 1. This method is called back. vscode's TextDocument has not yet been reloaded, so it has
62- // the version from before the changes are applied.
63- // 2. vscode reloads the file, and fires onDidChangeTextDocument. The document has been updated,
64- // and the changes have the delta.
65- // If we send this change to the server, then it will reload from the disk, which means it will
66- // be synchronized to the version after the changes. Then, onDidChangeTextDocument will fire and
67- // send the delta changes, which will cause the server to apply those exact changes. The results
68- // being that the file is now in an inconsistent state.
69- // If the document is closed, however, it will no longer be synchronized, so the text change will
70- // not be triggered and we should tell the server to reread from the disk.
71- return ;
57+ if ( changeType === FileChangeType . Change ) {
58+ const docs = workspace . textDocuments . filter ( doc => doc . uri . fsPath === uri . fsPath ) ;
59+ if ( Array . isArray ( docs ) && docs . some ( doc => ! doc . isClosed ) ) {
60+ // When a file changes on disk a FileSystemEvent is generated as well as a
61+ // DidChangeTextDocumentEvent.The ordering of these is:
62+ // 1. This method is called back. vscode's TextDocument has not yet been reloaded, so it has
63+ // the version from before the changes are applied.
64+ // 2. vscode reloads the file, and fires onDidChangeTextDocument. The document has been updated,
65+ // and the changes have the delta.
66+ // If we send this change to the server, then it will reload from the disk, which means it will
67+ // be synchronized to the version after the changes. Then, onDidChangeTextDocument will fire and
68+ // send the delta changes, which will cause the server to apply those exact changes. The results
69+ // being that the file is now in an inconsistent state.
70+ // If the document is closed, however, it will no longer be synchronized, so the text change will
71+ // not be triggered and we should tell the server to reread from the disk.
72+ return ;
73+ }
7274 }
7375
7476 const req = { FileName : uri . fsPath , changeType } ;
0 commit comments