diff --git a/CHANGELOG.md b/CHANGELOG.md index 370b47f..d88fbe5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Playlist retrieval crashing when list contains podcast episodes +- Crash when shifting a song by an amount greater than the queue's length ## [1.3.1] diff --git a/src/ui/queue.rs b/src/ui/queue.rs index b64dbbd..2fe0a3c 100644 --- a/src/ui/queue.rs +++ b/src/ui/queue.rs @@ -162,13 +162,21 @@ impl ViewExt for QueueView { _ => 1, }; + let mode = match mode { + &ShiftMode::Up if amount.is_negative() => &ShiftMode::Down, + &ShiftMode::Down if amount.is_negative() => &ShiftMode::Up, + m => m, + }; + + let amount = amount.abs(); + let selected = self.list.get_selected_index(); let len = self.queue.len(); match mode { ShiftMode::Up if selected > 0 => { self.queue - .shift(selected, (selected as i32).saturating_sub(amount) as usize); + .shift(selected, selected.saturating_sub(amount as usize)); self.list.move_focus(-amount); return Ok(CommandResult::Consumed(None)); }