aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop/handlers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs21
1 files changed, 8 insertions, 13 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 228eb7ce5..012f74270 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -556,24 +556,19 @@ pub fn handle_rename(world: ServerWorld, params: RenameParams) -> Result<Option<
556 .into()); 556 .into());
557 } 557 }
558 558
559 let refs = world 559 let renames = world
560 .analysis() 560 .analysis()
561 .find_all_refs(FilePosition { file_id, offset })?; 561 .rename(FilePosition { file_id, offset }, &*params.new_name)?;
562 if refs.is_empty() { 562 if renames.is_empty() {
563 return Ok(None); 563 return Ok(None);
564 } 564 }
565 565
566 let mut changes = HashMap::new(); 566 let mut changes = HashMap::new();
567 for r in refs { 567 for edit in renames {
568 if let Ok(loc) = to_location(r.0, r.1, &world, &line_index) { 568 changes
569 changes 569 .entry(file_id.try_conv_with(&world)?)
570 .entry(loc.uri) 570 .or_insert_with(Vec::new)
571 .or_insert_with(Vec::new) 571 .extend(edit.edit.conv_with(&line_index));
572 .push(TextEdit {
573 range: loc.range,
574 new_text: params.new_name.clone(),
575 });
576 }
577 } 572 }
578 573
579 Ok(Some(WorkspaceEdit { 574 Ok(Some(WorkspaceEdit {