feat: reuse the docked file tree for diff navigation

This commit is contained in:
2026-10-11 00:12:50 +02:00
parent 81a2bf9a02
commit 83c37f5a19
9 changed files with 531 additions and 117 deletions
+15 -18
View File
@@ -1281,6 +1281,9 @@ impl Editor {
fn handle_diff(&mut self, input: Input) {
// Escape and Tab always retain their modal close/back/focus semantics.
if !matches!(input, Input::Escape | Input::Char('\t') | Input::BackTab) {
if self.handle_tree_binding(&input) {
return;
}
match self.selection_bindings.get(&input) {
Some(Binding::Action(Action::Down)) => {
self.diff.as_mut().expect("active diff").navigate(true);
@@ -2544,7 +2547,11 @@ impl Editor {
}
pub fn file_navigation_hint(&self) -> &str {
if let Some(picker) = &self.file_picker
if let Some(picker) = self
.diff
.as_ref()
.and_then(|diff| diff.files.as_ref())
.or(self.file_picker.as_ref())
&& picker.view == FileView::Tree
{
if picker.searching {
@@ -2612,10 +2619,12 @@ impl Editor {
}
fn handle_tree_binding(&mut self, input: &Input) -> bool {
let Some(picker) = self
.file_picker
.as_mut()
.filter(|picker| picker.focused && picker.view == FileView::Tree)
let picker = if let Some(diff) = &mut self.diff {
diff.files.as_mut()
} else {
self.file_picker.as_mut()
};
let Some(picker) = picker.filter(|picker| picker.focused && picker.view == FileView::Tree)
else {
return false;
};
@@ -2897,19 +2906,7 @@ impl Editor {
}
Input::Ctrl('r') => picker.refresh(),
Input::Ctrl('t') => picker.toggle_view(),
Input::Ctrl('u') => picker.clear_filter(),
Input::Backspace if picker.view == FileView::List || picker.searching => {
picker.backspace()
}
Input::Char('i') if picker.view == FileView::Tree && !picker.searching => {
picker.start_search()
}
Input::Char(ch)
if !ch.is_control() && (picker.view == FileView::List || picker.searching) =>
{
picker.query.push(ch);
picker.refilter();
}
_ if picker.handle_filter_input(&input) => {}
Input::Enter => {
let Some(path) = picker.accept() else { return };
let source = self.jump_location();