From a9a7c5cb1f76f6d446e24a6867d404a62e60d8e2 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 20 Mar 2021 13:44:39 +0100 Subject: Don't return a SourceChange on WillRenameFiles when nothing gets refactored --- crates/rust-analyzer/src/handlers.rs | 7 +++++-- crates/rust-analyzer/tests/rust-analyzer/main.rs | 8 ++------ 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'crates') 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( source_change.file_system_edits.clear(); // no collect here because we want to merge text edits on same file ids source_change.extend(source_changes.map(|it| it.source_file_edits).flatten()); - let workspace_edit = to_proto::workspace_edit(&snap, source_change)?; - Ok(Some(workspace_edit)) + if source_change.source_file_edits.is_empty() { + Ok(None) + } else { + to_proto::workspace_edit(&snap, source_change).map(Some) + } } pub(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() {} new_uri: base_path.join("src/from_mod/foo.rs").to_str().unwrap().to_string(), }], }, - json!({ - "documentChanges": [] - }), + json!(null), ); //rename file from foo.rs to mod.rs @@ -851,9 +849,7 @@ fn main() {} new_uri: base_path.join("src/to_mod/mod.rs").to_str().unwrap().to_string(), }], }, - json!({ - "documentChanges": [] - }), + json!(null), ); //rename same level file -- cgit v1.2.3