« 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--todo.txt6
-rw-r--r--ui.js12
2 files changed, 12 insertions, 6 deletions
diff --git a/todo.txt b/todo.txt
index e0531f0..0db2382 100644
--- a/todo.txt
+++ b/todo.txt
@@ -457,3 +457,9 @@ TODO: Have a context menu option for creating a text file for notes on a
       (Done!)
 
 TODO: Delete notes files which are totally empty (or just a single line break).
+
+TODO: Only count *consistently* formatted text, across all tracks in a group,
+      as track numbering. See '19 3 In The Morning (Pianokind)' for example -
+      it is the only track in the group which is formatted '## # <text>'.
+      It does follow the formatting '## <text>' as all other tracks do, so only
+      the first digits, and following whitespace, should be removed.
diff --git a/ui.js b/ui.js
index 3753ff0..4f9b2e6 100644
--- a/ui.js
+++ b/ui.js
@@ -703,10 +703,10 @@ class AppElement extends FocusElement {
 
     grouplikeListing.pathElement.on('select', item => this.reveal(item))
     grouplikeListing.on('menu', (item, el) => this.showMenuForItemElement(el, grouplikeListing))
-    grouplikeListing.on('selected', item => this.editNotesFile(item, false))
+    grouplikeListing.on('selected', item => this.editNotesFile(item, grouplikeListing, false))
     grouplikeListing.on('edit-notes', item => {
       this.reveal(item)
-      this.editNotesFile(item, true)
+      this.editNotesFile(item, grouplikeListing, true)
     })
   }
 
@@ -861,7 +861,7 @@ class AppElement extends FocusElement {
     items.splice(items.indexOf(item), 0, file)
   }
 
-  async editNotesFile(item, focus) {
+  async editNotesFile(item, listing, focus) {
     if (!item) {
       return
     }
@@ -874,7 +874,7 @@ class AppElement extends FocusElement {
       await this.createNotesFile(item)
     }
 
-    const doubleCheckItem = () => item === this.tabber.currentElement.currentItem
+    const doubleCheckItem = () => item === listing.currentItem
 
     const status = await this.textEditor.openItem(item, {doubleCheckItem})
 
@@ -1028,8 +1028,8 @@ class AppElement extends FocusElement {
         canProcessMetadata && isTrack(item) && {label: 'Process metadata', action: () => this.processMetadata(item, true)},
         isOpenable(item) && item.url.endsWith('.json') && {label: 'Open (JSON Playlist)', action: () => this.openSpecialOrThroughSystem(item)},
         isOpenable(item) && {label: 'Open (System)', action: () => this.openThroughSystem(item)},
-        !hasNotesFile && isPlayable(item) && {label: 'Create notes file', action: () => this.editNotesFile(item, true)},
-        hasNotesFile && isPlayable(item) && {label: 'Edit notes file', action: () => this.editNotesFile(item, true)},
+        !hasNotesFile && isPlayable(item) && {label: 'Create notes file', action: () => this.editNotesFile(item, listing, true)},
+        hasNotesFile && isPlayable(item) && {label: 'Edit notes file', action: () => this.editNotesFile(item, listing, true)},
         canControlQueue && isPlayable(item) && {label: 'Remove from queue', action: () => this.unqueue(item)},
         {divider: true},