From e040b200bc0836f5d93afa8aef3bf47092ebf3f9 Mon Sep 17 00:00:00 2001 From: Zhang <17492978+zhang0098@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:15:42 +0800 Subject: [PATCH] project_panel: Make up/down in file rename editor not select items (#19670) Closes #19017 Release Notes: - Fixed project panel bug when renaming files where up/down keys could select other files. --- crates/editor/src/actions.rs | 2 +- crates/project_panel/src/project_panel.rs | 26 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/actions.rs b/crates/editor/src/actions.rs index 4955f00c38..5f866f9997 100644 --- a/crates/editor/src/actions.rs +++ b/crates/editor/src/actions.rs @@ -18,7 +18,7 @@ pub struct SelectPrevious { #[derive(PartialEq, Clone, Deserialize, Default)] pub struct MoveToBeginningOfLine { #[serde(default = "default_true")] - pub(super) stop_at_soft_wraps: bool, + pub stop_at_soft_wraps: bool, } #[derive(PartialEq, Clone, Deserialize, Default)] diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 4914809369..bbd1664b9d 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -726,6 +726,19 @@ impl ProjectPanel { } fn select_prev(&mut self, _: &SelectPrev, cx: &mut ViewContext) { + if let Some(edit_state) = &self.edit_state { + if edit_state.processing_filename.is_none() { + self.filename_editor.update(cx, |editor, cx| { + editor.move_to_beginning_of_line( + &editor::actions::MoveToBeginningOfLine { + stop_at_soft_wraps: false, + }, + cx, + ); + }); + return; + } + } if let Some(selection) = self.selection { let (mut worktree_ix, mut entry_ix, _) = self.index_for_selection(selection).unwrap_or_default(); @@ -1196,6 +1209,19 @@ impl ProjectPanel { } fn select_next(&mut self, _: &SelectNext, cx: &mut ViewContext) { + if let Some(edit_state) = &self.edit_state { + if edit_state.processing_filename.is_none() { + self.filename_editor.update(cx, |editor, cx| { + editor.move_to_end_of_line( + &editor::actions::MoveToEndOfLine { + stop_at_soft_wraps: false, + }, + cx, + ); + }); + return; + } + } if let Some(selection) = self.selection { let (mut worktree_ix, mut entry_ix, _) = self.index_for_selection(selection).unwrap_or_default();