handle last element removal in queue
This commit is contained in:
committed by
Henrik Friedrichsen
parent
4e7ec60b0e
commit
7bf0cac6c0
10
src/queue.rs
10
src/queue.rs
@@ -155,10 +155,14 @@ impl Queue {
|
||||
if let Some(current_track) = current {
|
||||
match current_track.cmp(&index) {
|
||||
Ordering::Equal => {
|
||||
// stop playback if we have the deleted the last item and it
|
||||
// was playing
|
||||
// if we have deleted the last item and it was playing
|
||||
// stop playback, unless repeat playlist is on, play next
|
||||
if current_track == len {
|
||||
self.stop();
|
||||
if self.get_repeat() == RepeatSetting::RepeatPlaylist {
|
||||
self.next(false);
|
||||
} else {
|
||||
self.stop();
|
||||
}
|
||||
} else {
|
||||
self.play(index, false, false);
|
||||
}
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user