fix regression/crash when directory becomes empty

This commit is contained in:
rabite 2020-01-24 23:30:34 +01:00
parent 42b1fe7507
commit b18e86f28e
2 changed files with 5 additions and 3 deletions

View File

@ -209,12 +209,13 @@ impl RefreshPackage {
// Need to unpack this to prevent issue with recursive Files type
// Also, if no files remain add placeholder and set len
let (files, new_len) = if files.len() > 0 {
(files.files, files.len)
let (files, new_len, new_buffer) = if files.len() > 0 {
(files.files, files.len, new_buffer)
} else {
let placeholder = File::new_placeholder(&files.directory.path).unwrap();
let buffer = vec![render_fn(&placeholder)];
files.files.push(placeholder);
(files.files, 1)
(files.files, 1, buffer)
};

View File

@ -112,6 +112,7 @@ impl Listable for ListView<Files> {
let path = &self.content.directory.path;
let placeholder = File::new_placeholder(&path)?;
self.content.files.push(placeholder);
self.content.len = 1;
}
let sender = self.core.get_sender();