diff --git a/NEWS b/NEWS index 3ab0b453b..25bf749f5 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ ver 0.20.11 (not yet released) * decoder - ffmpeg: more reliable song duration - gme: fix track numbering +* improve random song order when switching songs manually * fix case insensitive search without libicu * fix endless loop when accessing malformed file names in ZIP files diff --git a/src/queue/PlaylistControl.cxx b/src/queue/PlaylistControl.cxx index c2284b60c..2217756dd 100644 --- a/src/queue/PlaylistControl.cxx +++ b/src/queue/PlaylistControl.cxx @@ -63,15 +63,21 @@ playlist::MoveOrderToCurrent(unsigned old_order) /* no-op because there is no order list */ return old_order; - const unsigned destination_order = playing - ? (unsigned)current - : 0; - - /* swap the new song with the previous "current" one, so - playback continues as planned */ - queue.SwapOrders(old_order, destination_order); - - return destination_order; + if (playing) { + /* already playing: move the specified song after the + current one (because the current one has already + been playing and shall not be played again) */ + return queue.MoveOrderAfter(old_order, current); + } else if (current >= 0) { + /* not playing: move the specified song before the + current one, so it will be played eventually */ + return queue.MoveOrderBefore(old_order, current); + } else { + /* not playing anything: move the specified song to + the front */ + queue.SwapOrders(old_order, 0); + return 0; + } } void