Skip to content

Commit a9a7c5c

Browse files
committed
Don't return a SourceChange on WillRenameFiles when nothing gets refactored
1 parent d849124 commit a9a7c5c

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

crates/rust-analyzer/src/handlers.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,11 @@ pub(crate) fn handle_will_rename_files(
465465
source_change.file_system_edits.clear();
466466
// no collect here because we want to merge text edits on same file ids
467467
source_change.extend(source_changes.map(|it| it.source_file_edits).flatten());
468-
let workspace_edit = to_proto::workspace_edit(&snap, source_change)?;
469-
Ok(Some(workspace_edit))
468+
if source_change.source_file_edits.is_empty() {
469+
Ok(None)
470+
} else {
471+
to_proto::workspace_edit(&snap, source_change).map(Some)
472+
}
470473
}
471474

472475
pub(crate) fn handle_goto_definition(

crates/rust-analyzer/tests/rust-analyzer/main.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,7 @@ fn main() {}
838838
new_uri: base_path.join("src/from_mod/foo.rs").to_str().unwrap().to_string(),
839839
}],
840840
},
841-
json!({
842-
"documentChanges": []
843-
}),
841+
json!(null),
844842
);
845843

846844
//rename file from foo.rs to mod.rs
@@ -851,9 +849,7 @@ fn main() {}
851849
new_uri: base_path.join("src/to_mod/mod.rs").to_str().unwrap().to_string(),
852850
}],
853851
},
854-
json!({
855-
"documentChanges": []
856-
}),
852+
json!(null),
857853
);
858854

859855
//rename same level file

0 commit comments

Comments
 (0)