« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/ui.js b/ui.js
index 6965331..15c0d34 100644
--- a/ui.js
+++ b/ui.js
@@ -115,7 +115,9 @@ class AppElement extends FocusElement {
         afterItem = this.playingTrack
       }
 
-      this.queueGrouplikeItem(item, afterItem)
+      this.queueGrouplikeItem(item, afterItem, {
+        movePlayingTrack: !shuffle
+      })
 
       if (play) {
         this.playGrouplikeItem(item)
@@ -436,7 +438,7 @@ class AppElement extends FocusElement {
     this.player.kill()
   }
 
-  async queueGrouplikeItem(topItem, afterItem = null) {
+  async queueGrouplikeItem(topItem, afterItem = null, {movePlayingTrack = true} = {}) {
     const newTrackIndex = this.queueGrouplike.items.length
 
     const recursivelyAddTracks = item => {
@@ -458,6 +460,12 @@ class AppElement extends FocusElement {
       // is needed to fix the display, but then you end up with a new object
       // that doesn't work with indexOf).)
       if (items.includes(item)) {
+        // HOWEVER, if the "moveCurrentTrack" option is false, and that item
+        // is the one that's currently playing, we won't do anything with it
+        // at all.
+        if (!movePlayingTrack && item === this.playingTrack) {
+          return
+        }
         items.splice(items.indexOf(item), 1)
       }