handle last element removal in queue

This commit is contained in:
Moshe Sherman
2020-08-29 23:48:33 +03:00
committed by Henrik Friedrichsen
parent 4e7ec60b0e
commit 7bf0cac6c0
2 changed files with 14 additions and 4 deletions

View File

@@ -99,7 +99,13 @@ impl ViewExt for QueueView {
return Ok(CommandResult::Ignored);
}
Command::Delete => {
self.queue.remove(self.list.get_selected_index());
let selected = self.list.get_selected_index();
let len = self.queue.len();
self.queue.remove(selected);
if selected == len.saturating_sub(1) {
self.list.move_focus(-1);
}
return Ok(CommandResult::Consumed(None));
}
Command::Shift(mode, amount) => {