fix: show_hidden not properly applied to hovered folder (#124)

This commit is contained in:
三咲雅 · Misaki Masa 2023-09-08 06:47:51 +08:00 committed by GitHub
parent fa64047120
commit 567c617b28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 15 deletions

View File

@ -30,7 +30,7 @@ impl Manager {
pub fn refresh(&mut self) { pub fn refresh(&mut self) {
env::set_current_dir(self.cwd()).ok(); 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() { if let Some(f) = self.parent() {
self.watcher.trigger_dirs(&[self.cwd(), &f.cwd]); self.watcher.trigger_dirs(&[self.cwd(), &f.cwd]);
@ -342,10 +342,13 @@ impl Manager {
self.current_mut().update(op) self.current_mut().update(op)
} else if matches!(self.parent(), Some(p) if p.cwd == url) { } else if matches!(self.parent(), Some(p) if p.cwd == url) {
self.active_mut().parent.as_mut().unwrap().update(op) 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 { } else {
self.active_mut().history.entry(url.clone()).or_insert_with(|| Folder::from(&url)).update(op); self.active_mut().history.entry(url.clone()).or_insert_with(|| Folder::from(&url)).update(op);
false
matches!(self.hovered(), Some(h) if h.url() == &url)
}; };
b |= self.active_mut().parent.as_mut().map_or(false, |p| p.hover(&cwd)); b |= self.active_mut().parent.as_mut().map_or(false, |p| p.hover(&cwd));

View File

@ -422,28 +422,29 @@ impl Tab {
} }
self.show_hidden = state; self.show_hidden = state;
self.apply_show_hidden(); self.apply_show_hidden(false);
true 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 state = self.show_hidden;
let mut b = match self.current.hovered {
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 {
Some(ref h) if h.is_dir() => { Some(ref h) if h.is_dir() => {
self.history.get_mut(h.url()).map(|f| f.files.set_show_hidden(state)) == Some(true) self.history.get_mut(h.url()).map(|f| f.files.set_show_hidden(state)) == Some(true)
} }
_ => false, _ => 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(); self.current.hover_repos();
applied b
} }
} }