Skip to content

Commit

Permalink
fix: show_hidden not properly applied to hovered folder (sxyazi#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi authored Sep 7, 2023
1 parent fa64047 commit 567c617
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
9 changes: 6 additions & 3 deletions core/src/manager/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Manager {
pub fn refresh(&mut self) {
env::set_current_dir(self.cwd()).ok();

self.active_mut().apply_show_hidden();
self.active_mut().apply_show_hidden(false);

if let Some(f) = self.parent() {
self.watcher.trigger_dirs(&[self.cwd(), &f.cwd]);
Expand Down Expand Up @@ -342,10 +342,13 @@ impl Manager {
self.current_mut().update(op)
} else if matches!(self.parent(), Some(p) if p.cwd == url) {
self.active_mut().parent.as_mut().unwrap().update(op)
} else if matches!(self.hovered(), Some(h) if h.url() == &url) {
self.active_mut().history.entry(url.clone()).or_insert_with(|| Folder::from(&url));
self.active_mut().apply_show_hidden(true);
self.active_mut().history.get_mut(&url).unwrap().update(op)
} else {
self.active_mut().history.entry(url.clone()).or_insert_with(|| Folder::from(&url)).update(op);

matches!(self.hovered(), Some(h) if h.url() == &url)
false
};

b |= self.active_mut().parent.as_mut().map_or(false, |p| p.hover(&cwd));
Expand Down
25 changes: 13 additions & 12 deletions core/src/manager/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,28 +422,29 @@ impl Tab {
}

self.show_hidden = state;
self.apply_show_hidden();
self.apply_show_hidden(false);
true
}

pub fn apply_show_hidden(&mut self) -> bool {
pub fn apply_show_hidden(&mut self, only_hovered: bool) -> bool {
let state = self.show_hidden;

let mut applied = false;
applied |= self.current.files.set_show_hidden(state);

if let Some(parent) = self.parent.as_mut() {
applied |= parent.files.set_show_hidden(state);
}

applied |= match self.current.hovered {
let mut b = match self.current.hovered {
Some(ref h) if h.is_dir() => {
self.history.get_mut(h.url()).map(|f| f.files.set_show_hidden(state)) == Some(true)
}
_ => false,
};

if only_hovered {
return b;
}

b |= self.current.files.set_show_hidden(state);
if let Some(parent) = self.parent.as_mut() {
b |= parent.files.set_show_hidden(state);
}

self.current.hover_repos();
applied
b
}
}

0 comments on commit 567c617

Please sign in to comment.