aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-23 22:49:51 +0100
committerGitHub <[email protected]>2020-07-23 22:49:51 +0100
commit6ddcdb8b29f495f09b9e2456001be252d401e394 (patch)
treeffe91de0f89cde27abfb9a529e7ee8896728d560 /crates
parent45eb95d40ab5b169395685519e790eedd0082d53 (diff)
parentc9531dc797c0743b6d9c077363b90eea065f02d1 (diff)
Merge #5511
5511: Set the document version after changes are applied but before vfs r=kjeremy a=kjeremy Co-authored-by: kjeremy <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/main_loop.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index ac95e428e..e95d4157c 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -420,14 +420,17 @@ impl GlobalState {
420 })? 420 })?
421 .on::<lsp_types::notification::DidChangeTextDocument>(|this, params| { 421 .on::<lsp_types::notification::DidChangeTextDocument>(|this, params| {
422 if let Ok(path) = from_proto::vfs_path(&params.text_document.uri) { 422 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();
424 let vfs = &mut this.vfs.write().0; 424 let vfs = &mut this.vfs.write().0;
425 let file_id = vfs.file_id(&path).unwrap(); 425 let file_id = vfs.file_id(&path).unwrap();
426 let mut text = String::from_utf8(vfs.file_contents(file_id).to_vec()).unwrap(); 426 let mut text = String::from_utf8(vfs.file_contents(file_id).to_vec()).unwrap();
427 apply_document_changes(&mut text, params.content_changes); 427 apply_document_changes(&mut text, params.content_changes);
428 vfs.set_file_contents(path.clone(), Some(text.into_bytes()));
429 428
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()));
431 } 434 }
432 Ok(()) 435 Ok(())
433 })? 436 })?