c57287f61a6f0e6233d6d01a572de8657028b998
chmalee
  Mon Aug 28 09:55:09 2023 -0700
Fix bug in length spec search, if the user entered a length search, like chrA:X+Y, we first need to add Y to X before checking if the start and were a mistakenly swapped position, refs #32041,16721

diff --git src/hg/lib/hgFind.c src/hg/lib/hgFind.c
index 3bd4f03..b1162cd 100644
--- src/hg/lib/hgFind.c
+++ src/hg/lib/hgFind.c
@@ -3789,40 +3789,40 @@
     term = cloneString(term);
     /* Since we got a match, substrs[1] is the chrom/term, [2] is relStart, 
      * [3] is relEnd. ([0] is all.) */
     term[substrs[1].rm_eo] = 0;
     eraseTrailingSpaces(term);
     term[substrs[2].rm_eo] = 0;
     relStart = atoi(stripCommas(term+substrs[2].rm_so));
     term[substrs[3].rm_eo] = 0;
     if (singleBaseSpec)
         {
         relEnd   = relStart;
         relStart--;
         }
     else
         relEnd   = atoi(stripCommas(term+substrs[3].rm_so));
+    if (lengthSpec)
+        relEnd += relStart;
     if (relStart > relEnd)
         {
         int tmp  = relStart;
         relStart = relEnd;
         relEnd   = tmp;
         }
     if (canonicalSpec || gbrowserSpec || lengthSpec)
         relStart--;
-    if (lengthSpec)
-        relEnd += relStart;
     relativeFlag = TRUE;
     }
 term = cloneString(term); // because hgOfficialChromName mangles it
 
 if (hgOfficialChromName(db, term) != NULL) // this mangles the term
     {
     char *chrom;
     int start, end;
 
     hgParseChromRange(db, term, &chrom, &start, &end);
     if (relativeFlag)
 	{
 	int chromSize = end;
 	end = start + relEnd;
 	start = start + relStart;