Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix panic in rename selections (#11033)

Conrad Irwin03d0b68f0cd4
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index f51c3237ac3..b2b299e7803 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -8206,9 +8206,13 @@ impl Editor {
cursor_offset_in_rename_range_end..cursor_offset_in_rename_range
}
};
- editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
- s.select_ranges([rename_selection_range]);
- });
+ if rename_selection_range.end > old_name.len() {
+ editor.select_all(&SelectAll, cx);
+ } else {
+ editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
+ s.select_ranges([rename_selection_range]);
+ });
+ }
editor
});