« get me outta code hell

Merge branch 'preview' into networked-tags - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/find.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-10-10 09:45:38 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-10 09:45:38 -0300
commit76fb4dc0d70e60ddd30539bee3be6a7d3f44fad8 (patch)
tree8d763baeb60b1d6e641ddc3ec6c1f12fb8d8c9e9 /src/find.js
parent1407db7b8d745c22e40e904862d1b1562fe59f1b (diff)
parentf2381a1ee1e20dea5b23ea9d20c7a85b5b1c1c45 (diff)
Merge branch 'preview' into networked-tags
Diffstat (limited to 'src/find.js')
-rw-r--r--src/find.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/find.js b/src/find.js
index 141dd599..8e1a427b 100644
--- a/src/find.js
+++ b/src/find.js
@@ -34,11 +34,12 @@ export function processAllAvailableMatches(data, {
 
       const normalizedName = name.toLowerCase();
       if (normalizedName in byName) {
+        const alreadyMatchesByName = byName[normalizedName];
         byName[normalizedName] = null;
         if (normalizedName in multipleNameMatches) {
           multipleNameMatches[normalizedName].push(thing);
         } else {
-          multipleNameMatches[normalizedName] = [thing];
+          multipleNameMatches[normalizedName] = [alreadyMatchesByName, thing];
         }
       } else {
         byName[normalizedName] = thing;
@@ -97,16 +98,21 @@ function findHelper({
     const typePart = regexMatch[1];
     const refPart = regexMatch[2];
 
+    const normalizedName =
+      (typePart
+        ? null
+        : refPart.toLowerCase());
+
     const match =
       (typePart
         ? subcache.byDirectory[refPart]
-        : subcache.byName[refPart.toLowerCase()]);
+        : subcache.byName[normalizedName]);
 
     if (!match && !typePart) {
-      if (subcache.multipleNameMatches[refPart]) {
+      if (subcache.multipleNameMatches[normalizedName]) {
         return warnOrThrow(mode,
           `Multiple matches for reference "${fullRef}". Please resolve:\n` +
-          subcache.multipleNameMatches[refPart]
+          subcache.multipleNameMatches[normalizedName]
             .map(match => `- ${inspect(match)}\n`)
             .join('') +
           `Returning null for this reference.`);