diff options
Diffstat (limited to 'crates/ra_ide/src/references')
-rw-r--r-- | crates/ra_ide/src/references/rename.rs | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index 9acc6158a..fd17bc9f2 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs | |||
@@ -51,18 +51,15 @@ fn source_edit_from_reference(reference: Reference, new_name: &str) -> SourceFil | |||
51 | let mut replacement_text = String::new(); | 51 | let mut replacement_text = String::new(); |
52 | let file_id = reference.file_range.file_id; | 52 | let file_id = reference.file_range.file_id; |
53 | let range = match reference.kind { | 53 | let range = match reference.kind { |
54 | ReferenceKind::StructFieldShorthandForField => { | 54 | ReferenceKind::FieldShorthandForField => { |
55 | replacement_text.push_str(new_name); | 55 | replacement_text.push_str(new_name); |
56 | replacement_text.push_str(": "); | 56 | replacement_text.push_str(": "); |
57 | TextRange::from_to( | 57 | TextRange::new(reference.file_range.range.start(), reference.file_range.range.start()) |
58 | reference.file_range.range.start(), | ||
59 | reference.file_range.range.start(), | ||
60 | ) | ||
61 | } | 58 | } |
62 | ReferenceKind::StructFieldShorthandForLocal => { | 59 | ReferenceKind::FieldShorthandForLocal => { |
63 | replacement_text.push_str(": "); | 60 | replacement_text.push_str(": "); |
64 | replacement_text.push_str(new_name); | 61 | replacement_text.push_str(new_name); |
65 | TextRange::from_to(reference.file_range.range.end(), reference.file_range.range.end()) | 62 | TextRange::new(reference.file_range.range.end(), reference.file_range.range.end()) |
66 | } | 63 | } |
67 | _ => { | 64 | _ => { |
68 | replacement_text.push_str(new_name); | 65 | replacement_text.push_str(new_name); |
@@ -528,7 +525,7 @@ mod tests { | |||
528 | @r###" | 525 | @r###" |
529 | Some( | 526 | Some( |
530 | RangeInfo { | 527 | RangeInfo { |
531 | range: [4; 7), | 528 | range: 4..7, |
532 | info: SourceChange { | 529 | info: SourceChange { |
533 | label: "rename", | 530 | label: "rename", |
534 | source_file_edits: [ | 531 | source_file_edits: [ |
@@ -539,7 +536,7 @@ mod tests { | |||
539 | edit: TextEdit { | 536 | edit: TextEdit { |
540 | atoms: [ | 537 | atoms: [ |
541 | AtomTextEdit { | 538 | AtomTextEdit { |
542 | delete: [4; 7), | 539 | delete: 4..7, |
543 | insert: "foo2", | 540 | insert: "foo2", |
544 | }, | 541 | }, |
545 | ], | 542 | ], |
@@ -580,7 +577,7 @@ mod tests { | |||
580 | @r###" | 577 | @r###" |
581 | Some( | 578 | Some( |
582 | RangeInfo { | 579 | RangeInfo { |
583 | range: [4; 7), | 580 | range: 4..7, |
584 | info: SourceChange { | 581 | info: SourceChange { |
585 | label: "rename", | 582 | label: "rename", |
586 | source_file_edits: [ | 583 | source_file_edits: [ |
@@ -591,7 +588,7 @@ mod tests { | |||
591 | edit: TextEdit { | 588 | edit: TextEdit { |
592 | atoms: [ | 589 | atoms: [ |
593 | AtomTextEdit { | 590 | AtomTextEdit { |
594 | delete: [4; 7), | 591 | delete: 4..7, |
595 | insert: "foo2", | 592 | insert: "foo2", |
596 | }, | 593 | }, |
597 | ], | 594 | ], |
@@ -663,7 +660,7 @@ mod tests { | |||
663 | @r###" | 660 | @r###" |
664 | Some( | 661 | Some( |
665 | RangeInfo { | 662 | RangeInfo { |
666 | range: [8; 11), | 663 | range: 8..11, |
667 | info: SourceChange { | 664 | info: SourceChange { |
668 | label: "rename", | 665 | label: "rename", |
669 | source_file_edits: [ | 666 | source_file_edits: [ |
@@ -674,7 +671,7 @@ mod tests { | |||
674 | edit: TextEdit { | 671 | edit: TextEdit { |
675 | atoms: [ | 672 | atoms: [ |
676 | AtomTextEdit { | 673 | AtomTextEdit { |
677 | delete: [8; 11), | 674 | delete: 8..11, |
678 | insert: "foo2", | 675 | insert: "foo2", |
679 | }, | 676 | }, |
680 | ], | 677 | ], |
@@ -687,7 +684,7 @@ mod tests { | |||
687 | edit: TextEdit { | 684 | edit: TextEdit { |
688 | atoms: [ | 685 | atoms: [ |
689 | AtomTextEdit { | 686 | AtomTextEdit { |
690 | delete: [27; 30), | 687 | delete: 27..30, |
691 | insert: "foo2", | 688 | insert: "foo2", |
692 | }, | 689 | }, |
693 | ], | 690 | ], |