« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ui.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/ui.js b/ui.js
index 8945ce0..20cfd99 100644
--- a/ui.js
+++ b/ui.js
@@ -1583,14 +1583,15 @@ class AppElement extends FocusElement {
     }
 
     if (where === 'next' || where === 'after-selected' || where === 'before-selected' || where === 'end') {
+      const selected = this.queueListingElement.currentItem
       let afterItem = null
       if (where === 'next') {
         afterItem = playingTrack
       } else if (where === 'after-selected') {
-        afterItem = this.queueListingElement.currentItem
+        afterItem = selected
       } else if (where === 'before-selected') {
         const { items } = this.SQP.queueGrouplike
-        const index = items.indexOf(this.queueListingElement.currentItem)
+        const index = items.indexOf(selected)
         if (index === 0) {
           afterItem = 'FRONT'
         } else if (index > 0) {
@@ -1599,11 +1600,13 @@ class AppElement extends FocusElement {
       }
 
       this.SQP.queue(item, afterItem, {
-        movePlayingTrack: order === 'normal'
+        movePlayingTrack: order === 'normal' || order === 'alphabetic'
       })
 
       if (isTrack(passedItem)) {
         this.queueListingElement.selectAndShow(passedItem)
+      } else {
+        this.queueListingElement.selectAndShow(selected)
       }
     } else if (where.startsWith('distribute-')) {
       this.SQP.distributeQueue(item, {