From 2695b1394754d90d1d3c14d47ed43b07ee0debab Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 15 Apr 2022 10:26:39 +0200 Subject: [PATCH] Always clear rename state when selections change At some point during the implementation of rename, we added logic for invalidating the rename state when the selection moved outside the original rename range. After transitioning to displaying renames as a block decoration, we don't need that anymore given that a new, temporary editor is used instead. This commit removes that invalidation logic and always calls `Editor::take_rename` when the editor selections change. Doing so also fixes a bug that was causing Zed to hide the cursor when clicking on the editor to dismiss the rename. --- crates/editor/src/editor.rs | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 4822d4557076a6614b706b8ec4d27e76e14b3d00..97be28ebd420163a96a100073fd1a1a46c8e0df1 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -4808,25 +4808,6 @@ impl Editor { Some(rename) } - fn invalidate_rename_range( - &mut self, - buffer: &MultiBufferSnapshot, - cx: &mut ViewContext, - ) { - if let Some(rename) = self.pending_rename.as_ref() { - if self.selections.len() == 1 { - let head = self.selections[0].head().to_offset(buffer); - let range = rename.range.to_offset(buffer).to_inclusive(); - if range.contains(&head) { - return; - } - } - let rename = self.pending_rename.take().unwrap(); - self.remove_blocks([rename.block_id].into_iter().collect(), cx); - self.clear_background_highlights::(cx); - } - } - #[cfg(any(test, feature = "test-support"))] pub fn pending_rename(&self) -> Option<&RenameState> { self.pending_rename.as_ref() @@ -5332,7 +5313,7 @@ impl Editor { self.select_larger_syntax_node_stack.clear(); self.autoclose_stack.invalidate(&self.selections, &buffer); self.snippet_stack.invalidate(&self.selections, &buffer); - self.invalidate_rename_range(&buffer, cx); + self.take_rename(false, cx); let new_cursor_position = self.newest_anchor_selection().head();