9c2d11ccfb0c87e3561b584b1413bd0e21f9b285
hiram
  Thu Sep 5 14:30:47 2024 -0700
correctly highlight a compound word even when * wildcard included refs #32596

diff --git src/hg/js/assemblySearch.js src/hg/js/assemblySearch.js
index ad092a5..5cb6ac9 100644
--- src/hg/js/assemblySearch.js
+++ src/hg/js/assemblySearch.js
@@ -289,58 +289,72 @@
 //  queryString.  This is tricky, there are extra characters besides
 //  just [a-zA-Z] that are getting in the way of these matches, where
 //  the MySQL could match, for example: checking:
 //      'HG02257' =? '(HG02257.pat'
 //      'HG02257' =? 'HG02257.alt.pat.f1_v2'
 //  doesn't match here, but MySQL match did
 
 function highlightMatch(queryString, rowData) {
     // fixup the queryString words to get rid of the special characters
     var words = queryString.split(/\s+/);
     var wholeWord = [];	// going to be words that match completely
     var prefix = [];	// going to be words that match prefix
     for (let word of words) {
        var noPrefix = word.replace(/^[-+]/, '');	// remove + - beginning
        if (noPrefix.endsWith("*")) {
+         let subPrefix = noPrefix.replace(/\*$/, '').match(/(\w+)/g);
+         if (subPrefix.length > 1) {
+           let i = 0;
+           for ( ; i < subPrefix.length - 1; i++) {
+              wholeWord.push(subPrefix[i]);
+           }
+           prefix.push(subPrefix[i].replace(/\*$/, ''));
+         } else {
            prefix.push(noPrefix.replace(/\*$/, ''));
+         }
        } else {
          wholeWord.push(noPrefix);
        }
     }
     if (wholeWord.length > 0) {
       for (let word of wholeWord) {
         for (let key in rowData) {
            if (rowData.hasOwnProperty(key)) {
               if (typeof rowData[key] === 'string') {
                  let value = rowData[key];
                  let subWords = value.match(/(\w+)|(\W+)/g);
                  let newString = "";
+                 let wholeSubs = word.match(/(\w+)/g);
+                 if (wholeSubs.length > 0) {
+                   for (let whole of wholeSubs) {
                      for (let subWord of subWords) {
-                   if ( word.toLowerCase() === subWord.toLowerCase() ) {
+                       if ( whole.toLowerCase() === subWord.toLowerCase() ) {
                           newString += "<span class='highlight'>" + subWord + "</span>";
                        } else {
                           newString += subWord;
                        }
                      }
                      newString = newString.trim();
                      if (newString !== rowData[key])
                         rowData[key] = newString;
-              }
-           }
-        }
-      }
-    }
+                   }	//	for (let whole of wholeSubs)
+                 }	//	if (wholeSubs.length > 0)
+              }	//	if (typeof rowData[key] === 'string')
+           }	//	if (rowData.hasOwnProperty(key))
+        }	//	for (let key in rowData)
+      }	//	for (let word of wholeWord)
+    }	//	if (wholeWord.length > 0)
     if (prefix.length > 0) {
       for (let word of prefix) {
         for (let key in rowData) {
            if (rowData.hasOwnProperty(key)) {
               if (typeof rowData[key] === 'string') {
                  let value = rowData[key];
                  let subWords = value.match(/(\w+)|(\W+)/g);
                  let newString = "";
                  for (let subWord of subWords) {
                    if ( subWord.toLowerCase().startsWith(word.toLowerCase())) {
                       newString += "<span class='highlight'>" + subWord + "</span>";
                    } else {
                       newString += subWord;
                    }
                  }