aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-03-20 12:44:39 +0000
committerLukas Wirth <[email protected]>2021-03-20 12:57:58 +0000
commita9a7c5cb1f76f6d446e24a6867d404a62e60d8e2 (patch)
treebc82a780bee6b929ab66e1bacef5b9b1abdc3ada /crates
parentd84912483dcdf568d8abd1c11832661758412f00 (diff)
Don't return a SourceChange on WillRenameFiles when nothing gets refactored
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/handlers.rs7
-rw-r--r--crates/rust-analyzer/tests/rust-analyzer/main.rs8
2 files changed, 7 insertions, 8 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index b6f484e51..880fea622 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -465,8 +465,11 @@ pub(crate) fn handle_will_rename_files(
465 source_change.file_system_edits.clear(); 465 source_change.file_system_edits.clear();
466 // no collect here because we want to merge text edits on same file ids 466 // no collect here because we want to merge text edits on same file ids
467 source_change.extend(source_changes.map(|it| it.source_file_edits).flatten()); 467 source_change.extend(source_changes.map(|it| it.source_file_edits).flatten());
468 let workspace_edit = to_proto::workspace_edit(&snap, source_change)?; 468 if source_change.source_file_edits.is_empty() {
469 Ok(Some(workspace_edit)) 469 Ok(None)
470 } else {
471 to_proto::workspace_edit(&snap, source_change).map(Some)
472 }
470} 473}
471 474
472pub(crate) fn handle_goto_definition( 475pub(crate) fn handle_goto_definition(
diff --git a/crates/rust-analyzer/tests/rust-analyzer/main.rs b/crates/rust-analyzer/tests/rust-analyzer/main.rs
index 7545b4a34..19516de7b 100644
--- a/crates/rust-analyzer/tests/rust-analyzer/main.rs
+++ b/crates/rust-analyzer/tests/rust-analyzer/main.rs
@@ -838,9 +838,7 @@ fn main() {}
838 new_uri: base_path.join("src/from_mod/foo.rs").to_str().unwrap().to_string(), 838 new_uri: base_path.join("src/from_mod/foo.rs").to_str().unwrap().to_string(),
839 }], 839 }],
840 }, 840 },
841 json!({ 841 json!(null),
842 "documentChanges": []
843 }),
844 ); 842 );
845 843
846 //rename file from foo.rs to mod.rs 844 //rename file from foo.rs to mod.rs
@@ -851,9 +849,7 @@ fn main() {}
851 new_uri: base_path.join("src/to_mod/mod.rs").to_str().unwrap().to_string(), 849 new_uri: base_path.join("src/to_mod/mod.rs").to_str().unwrap().to_string(),
852 }], 850 }],
853 }, 851 },
854 json!({ 852 json!(null),
855 "documentChanges": []
856 }),
857 ); 853 );
858 854
859 //rename same level file 855 //rename same level file