File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -420,14 +420,17 @@ impl GlobalState {
420420 } ) ?
421421 . on :: < lsp_types:: notification:: DidChangeTextDocument > ( |this, params| {
422422 if let Ok ( path) = from_proto:: vfs_path ( & params. text_document . uri ) {
423- * this. mem_docs . get_mut ( & path) . unwrap ( ) = params . text_document . version ;
423+ let doc = this. mem_docs . get_mut ( & path) . unwrap ( ) ;
424424 let vfs = & mut this. vfs . write ( ) . 0 ;
425425 let file_id = vfs. file_id ( & path) . unwrap ( ) ;
426426 let mut text = String :: from_utf8 ( vfs. file_contents ( file_id) . to_vec ( ) ) . unwrap ( ) ;
427427 apply_document_changes ( & mut text, params. content_changes ) ;
428- vfs. set_file_contents ( path. clone ( ) , Some ( text. into_bytes ( ) ) ) ;
429428
430- this. mem_docs . insert ( path, params. text_document . version ) ;
429+ // The version passed in DidChangeTextDocument is the version after all edits are applied
430+ // so we should apply it before the vfs is notified.
431+ * doc = params. text_document . version ;
432+
433+ vfs. set_file_contents ( path. clone ( ) , Some ( text. into_bytes ( ) ) ) ;
431434 }
432435 Ok ( ( ) )
433436 } ) ?
You can’t perform that action at this time.
0 commit comments