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.
This commit is contained in:
Zhang 2024-10-24 18:15:42 +08:00 committed by GitHub
parent 1dba50f42f
commit e040b200bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 1 deletions

View file

@ -726,6 +726,19 @@ impl ProjectPanel {
}
fn select_prev(&mut self, _: &SelectPrev, cx: &mut ViewContext<Self>) {
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<Self>) {
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();