fix: the parent does not hover properly on switching the hidden state (#339)

This commit is contained in:
三咲雅 · Misaki Masa 2023-11-06 00:22:32 +08:00 committed by GitHub
parent 847c475d8c
commit dcb4944974
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View file

@ -93,6 +93,10 @@ impl Folder {
}
pub fn hover(&mut self, url: &Url) -> bool {
if self.hovered().map(|h| &h.url) == Some(url) {
return false;
}
let new = self.files.position(url).unwrap_or(self.cursor);
if new > self.cursor {
self.next(Step::next(new - self.cursor))

View file

@ -100,28 +100,29 @@ impl Tab {
}
pub fn apply_files_attrs(&mut self, just_preview: bool) -> bool {
let apply = |f: &mut Folder| {
let hovered = f.hovered().map(|h| h.url());
let mut b = f.files.set_show_hidden(self.conf.show_hidden);
b |= f.files.set_sorter(self.conf.sorter());
b | f.repos(hovered)
};
let mut b = false;
if let Some(f) =
self.current.hovered().filter(|h| h.is_dir()).and_then(|h| self.history.get_mut(&h.url))
{
b |= f.files.set_show_hidden(self.conf.show_hidden);
b |= f.files.set_sorter(self.conf.sorter());
b |= apply(f);
}
if just_preview {
return b;
}
let hovered = self.current.hovered().map(|h| h.url());
b |= self.current.files.set_show_hidden(self.conf.show_hidden);
b |= self.current.files.set_sorter(self.conf.sorter());
b |= apply(&mut self.current);
if let Some(parent) = self.parent.as_mut() {
b |= parent.files.set_show_hidden(self.conf.show_hidden);
b |= parent.files.set_sorter(self.conf.sorter());
b |= apply(parent);
}
self.current.repos(hovered);
b
}
}