add/remove placeholder when dir becomes empty/populated

This commit is contained in:
rabite 2019-04-09 19:22:42 +02:00
parent ee3b82f85d
commit 1fd25d35c3
1 changed files with 15 additions and 0 deletions

View File

@ -363,10 +363,25 @@ impl Files {
new.selected = selected;
self.files.push(new);
});
self.sort();
if self.len() == 0 {
let placeholder = File::new_placeholder(&self.directory.path)?;
self.files.push(placeholder);
} else {
self.remove_placeholder();
}
Ok(())
}
fn remove_placeholder(&mut self) {
let dirpath = self.directory.path.clone();
self.find_file_with_path(&dirpath).cloned()
.map(|placeholder| self.files.remove_item(&placeholder));
}
pub fn handle_event(&mut self,
event: &DebouncedEvent) -> HResult<()> {
match event {