c1344ba327a9e1acaf267653730de9f532087c5e
angie
  Fri Apr 4 12:31:55 2014 -0700
When we have multiple position matches, restore lastPosition(or defaultPosition).
fixes #13009

diff --git src/hg/hgVai/hgVai.c src/hg/hgVai/hgVai.c
index b181842..ff63bd7 100644
--- src/hg/hgVai/hgVai.c
+++ src/hg/hgVai/hgVai.c
@@ -145,31 +145,31 @@
 {
 printf("<span style='display: inline-block; padding-right: 5px;'>"
        "<span style='display: block;'>%s</span>\n"
        "<span style='display: block; padding-bottom: 5px;'>\n", label);
 }
 
 void topLabelSpansEnd()
 {
 printf("</span></span>");
 }
 
 char *makePositionInput()
 /* Return HTML for the position input. */
 {
 struct dyString *dy = dyStringCreate("<INPUT TYPE=TEXT NAME=\"%s\" SIZE=%d VALUE=\"%s\">",
-				     hgvaRange, 26,
+				     hgvaRange, 45,
 				     addCommasToPos(NULL, cartString(cart, hgvaRange)));
 return dyStringCannibalize(&dy);
 }
 
 void printCtAndHubButtons()
 /* Print a div with buttons for hgCustom and hgHubConnect */
 {
 puts("<div style='padding-top: 5px; padding-bottom: 5px'>");
 hOnClickButton("document.customTrackForm.submit(); return false;",
 	       hasCustomTracks(cart) ? CT_MANAGE_BUTTON_LABEL : CT_ADD_BUTTON_LABEL);
 printf(" ");
 if (hubConnectTableExists())
     hOnClickButton("document.trackHubForm.submit(); return false;", "track hubs");
 nbSpaces(3);
 printf("To reset <B>all</B> user cart settings (including custom tracks), \n"
@@ -1956,30 +1956,35 @@
     cartSetString(cart, hgvaRange, hDefaultPos(database));
 
 int timeout = cartUsualInt(cart, "udcTimeout", 300);
 if (udcCacheTimeout() < timeout)
     udcSetCacheTimeout(timeout);
 knetUdcInstall();
 
 initGroupsTracksTables(cart, &fullTrackList, &fullGroupList);
 if (lookupPosition(cart, hgvaRange))
     {
     if (startQuery)
 	doQuery();
     else
 	doUi();
     }
-else if (webGotWarnings())
+else
     {
-    // We land here when lookupPosition pops up a warning box.
-    // Reset the problematic position and show the main page.
+    // Revert to lastPosition if we have multiple matches or warnings,
+    // especially in case user manually edits browser location as in #13009:
     char *position = cartUsualString(cart, "lastPosition", hDefaultPos(database));
     cartSetString(cart, hgvaRange, position);
+    if (webGotWarnings())
+	{
+	// We land here when lookupPosition pops up a warning box.
+	// Reset the problematic position and show the main page.
 	doMainPage();
 	}
     // If lookupPosition returned FALSE and didn't report warnings,
     // then it wrote HTML showing multiple position matches & links.
+    }
 
 cartCheckout(&cart);
 cgiExitTime("hgVai", enteredMainTime);
 return 0;
 }