Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 253f720

Browse files
committed
Exit glob mode if view root is the same as glob root
1 parent 13614a9 commit 253f720

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/interactive/app/eventloop.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ impl AppState {
283283
Char('o') | Char('l') | Enter | Right => {
284284
self.enter_node_with_traversal(&tree_view)
285285
}
286-
Char('R') => self.refresh(&mut tree_view, Refresh::Selected)?,
287-
Char('r') => self.refresh(&mut tree_view, Refresh::AllInView)?,
286+
Char('R') => self.refresh(&mut tree_view, window, Refresh::Selected)?,
287+
Char('r') => self.refresh(&mut tree_view, window, Refresh::AllInView)?,
288288
Char('H') | Home => self.change_entry_selection(CursorDirection::ToTop),
289289
Char('G') | End => self.change_entry_selection(CursorDirection::ToBottom),
290290
PageUp => self.change_entry_selection(CursorDirection::PageUp),
@@ -321,8 +321,14 @@ impl AppState {
321321
Ok(None)
322322
}
323323

324-
fn refresh(&mut self, tree: &mut TreeView<'_>, what: Refresh) -> anyhow::Result<()> {
325-
let (remove_index, skip_root, index, parent_index) = match what {
324+
fn refresh(&mut self, tree: &mut TreeView<'_>, window: &mut MainWindow, what: Refresh) -> anyhow::Result<()> {
325+
if let Some(glob_tree_root) = tree.glob_tree_root {
326+
if glob_tree_root == self.navigation().view_root {
327+
self.quit_glob_mode(tree, window)
328+
}
329+
}
330+
331+
let (remove_index, skip_root, index, parent_index) = match what {
326332
Refresh::Selected => {
327333
let Some(selected) = self.navigation().selected else {
328334
return Ok(());
@@ -414,7 +420,7 @@ impl AppState {
414420
match self.focussed {
415421
Main => {
416422
if self.glob_navigation.is_some() {
417-
self.handle_glob_quit(tree_view, window);
423+
self.quit_glob_mode(tree_view, window);
418424
} else {
419425
return Some(Ok(WalkResult {
420426
num_errors: self.stats.io_errors,
@@ -427,13 +433,13 @@ impl AppState {
427433
window.help_pane = None
428434
}
429435
Glob => {
430-
self.handle_glob_quit(tree_view, window);
436+
self.quit_glob_mode(tree_view, window);
431437
}
432438
}
433439
None
434440
}
435441

436-
fn handle_glob_quit(&mut self, tree_view: &mut TreeView<'_>, window: &mut MainWindow) {
442+
fn quit_glob_mode(&mut self, tree_view: &mut TreeView<'_>, window: &mut MainWindow) {
437443
use FocussedPane::*;
438444
self.focussed = Main;
439445
if let Some(glob_source) = &self.glob_navigation {

0 commit comments

Comments
 (0)