Simplify the code

This commit is contained in:
sxyazi 2024-02-18 19:23:06 +08:00
parent 24243e6c60
commit ce6a9e486b
No known key found for this signature in database
2 changed files with 17 additions and 22 deletions

View file

@ -38,7 +38,7 @@ impl Notify {
if m.timeout.is_zero() { if m.timeout.is_zero() {
m.percent = m.percent.saturating_sub(20); m.percent = m.percent.saturating_sub(20);
} else if m.percent < 100 { } else if m.percent < 100 {
m.percent = m.percent.saturating_add(20); m.percent += 20;
} else { } else {
m.timeout = m.timeout.saturating_sub(opt.interval); m.timeout = m.timeout.saturating_sub(opt.interval);
} }

View file

@ -103,28 +103,23 @@ impl Tab {
return true; return true;
}; };
let results: Vec<_> = indices let mut success = true;
.iter() for f in indices.iter().filter_map(|i| self.current.files.get(*i)) {
.filter_map(|i| self.current.files.get(*i)) if state {
.map(|f| { success &= self.selected.add(&f.url);
if state { } else {
self.selected.add(&f.url) self.selected.remove(&f.url);
} else { }
self.selected.remove(&f.url);
true
}
})
.collect();
render!(!results.is_empty());
if results.into_iter().all(|b| b) {
return true;
} }
Notify::_push_warn( if !success {
"Escape visual mode", Notify::_push_warn(
"Some files cannot be selected due to path nesting conflict.", "Escape visual mode",
); "Some files cannot be selected, due to path nesting conflict.",
false );
}
render!();
success
} }
} }