mirror of https://github.com/bobwen-dev/hunter
create placeholder when folder is empty when hiding files
This commit is contained in:
parent
d41ee4aedb
commit
127c3e89a4
|
@ -342,7 +342,12 @@ impl Files {
|
|||
}
|
||||
|
||||
pub fn toggle_hidden(&mut self) {
|
||||
self.show_hidden = !self.show_hidden
|
||||
self.show_hidden = !self.show_hidden;
|
||||
self.set_dirty();
|
||||
|
||||
if self.show_hidden == true {
|
||||
self.remove_placeholder();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_file(&mut self,
|
||||
|
|
|
@ -130,6 +130,7 @@ impl FsCache {
|
|||
let files = self.get_files(&dir, Stale::new())?.1;
|
||||
let mut files = files.wait()?;
|
||||
FsCache::apply_settingss(&self, &mut files).ok();
|
||||
let files = FsCache::ensure_not_empty(files)?;
|
||||
Ok(files)
|
||||
}
|
||||
|
||||
|
@ -230,6 +231,7 @@ impl FsCache {
|
|||
}
|
||||
|
||||
files.sort();
|
||||
let files = FsCache::ensure_not_empty(files)?;
|
||||
Ok(files)
|
||||
}));
|
||||
|
||||
|
@ -265,6 +267,15 @@ impl FsCache {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn ensure_not_empty(mut files: Files) -> HResult<Files> {
|
||||
if files.len() == 0 {
|
||||
let path = &files.directory.path;
|
||||
let placeholder = File::new_placeholder(&path)?;
|
||||
files.files.push(placeholder);
|
||||
}
|
||||
Ok(files)
|
||||
}
|
||||
|
||||
|
||||
fn extract_tab_settings(files: &Files, selection: Option<File>) -> TabSettings {
|
||||
TabSettings {
|
||||
|
|
|
@ -35,6 +35,12 @@ impl Listable for ListView<Files> {
|
|||
}
|
||||
|
||||
fn on_refresh(&mut self) -> HResult<()> {
|
||||
if self.content.len() == 0 {
|
||||
let path = &self.content.directory.path;
|
||||
let placeholder = File::new_placeholder(&path)?;
|
||||
self.content.files.push(placeholder);
|
||||
}
|
||||
|
||||
let sender = self.core.get_sender();
|
||||
|
||||
let visible_files = self.core.coordinates.size_u().1 + self.offset + 1;
|
||||
|
|
Loading…
Reference in New Issue