19caadce837026ea1e2a45844b34efc4928d3efb
chmalee
  Mon Oct 31 20:29:27 2022 -0700
Fixes for searches noted in #30201 note 2. The hgTracks search bar strips commas out of queries for some reason, and work around a swapped chromStart/chromEnd bug found in an hgvs search, refs #30201

diff --git src/hg/hgSearch/hgSearch.c src/hg/hgSearch/hgSearch.c
index a609c27..5e46180 100644
--- src/hg/hgSearch/hgSearch.c
+++ src/hg/hgSearch/hgSearch.c
@@ -174,30 +174,37 @@
     {
     // if we got an hgvs match to chromInfo (example: chrX:g.31500000_31600000del),
     // or just a plain position range was searched, we have to create the json
     // manually, cause the tdb lookups in hgPositionsJson() won't work
     struct hgPosTable *table = hgp->tableList;
     jsonWriteListStart(jw, "positionMatches");
     jsonWriteObjectStart(jw, NULL);
     jsonWriteString(jw, "name", table->name);
     jsonWriteString(jw, "description", table->description);
     if (table->searchTime >= 0)
         jsonWriteNumber(jw, "searchTime", table->searchTime);
     jsonWriteListStart(jw, "matches");
 
     jsonWriteObjectStart(jw, NULL);
     char position[512];
+    retWinStart = hgp->singlePos->chromStart;
+    retWinEnd = hgp->singlePos->chromEnd;
+    if (hgp->singlePos->chromStart > hgp->singlePos->chromEnd)
+        {
+        retWinStart = retWinEnd;
+        retWinEnd = hgp->singlePos->chromStart;
+        }
     safef(position, sizeof(position), "%s:%d-%d", hgp->singlePos->chrom, retWinStart+1, retWinEnd);
     jsonWriteString(jw, "position", position);
     jsonWriteString(jw, "posName", hgp->query);
     if (doRedirect)
         {
         // If we are coming from hgTracks or hgGateway, then we can just return right
         // back to hgTracks, the client will handle this:
         jsonWriteBoolean(jw, "doRedirect", doRedirect);
         }
     jsonWriteObjectEnd(jw);
 
     jsonWriteListEnd(jw); // end matches
     jsonWriteObjectEnd(jw); // end one table
     jsonWriteListEnd(jw); // end positionMatches
     }