spike branch updated from latest features/JAL-2446
[jalview.git] / src / jalview / appletgui / SeqPanel.java
index 9e31efe..42e4d8e 100644 (file)
@@ -577,7 +577,8 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         seqCanvas.highlightSearchResults(highlight);
         seqCanvas.getFeatureRenderer().amendFeatures(
                 Collections.singletonList(sequence), features, false, ap);
-        seqCanvas.highlightSearchResults(null);
+        av.setSearchResults(null); // clear highlighting
+        seqCanvas.repaint(); // draw new/amended features
       }
     }
   }
@@ -615,6 +616,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     int res = 0;
     int x = evt.getX();
 
+    int startRes = av.getRanges().getStartRes();
     if (av.getWrapAlignment())
     {
 
@@ -629,7 +631,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
 
       int y = evt.getY();
       y -= hgap;
-      x -= seqCanvas.LABEL_WEST;
+      x = Math.max(0, x - seqCanvas.LABEL_WEST);
 
       int cwidth = seqCanvas.getWrappedCanvasWidth(getSize().width);
       if (cwidth < 1)
@@ -638,14 +640,15 @@ public class SeqPanel extends Panel implements MouseMotionListener,
       }
 
       wrappedBlock = y / cHeight;
-      wrappedBlock += av.getRanges().getStartRes() / cwidth;
-
-      res = wrappedBlock * cwidth + x / av.getCharWidth();
-
+      wrappedBlock += startRes / cwidth;
+      int startOffset = startRes % cwidth; // in case start is scrolled right
+                                           // from 0
+      res = wrappedBlock * cwidth
+              + Math.min(cwidth - 1, startOffset + x / av.getCharWidth());
     }
     else
     {
-      res = (x / av.getCharWidth()) + av.getRanges().getStartRes();
+      res = (x / av.getCharWidth()) + startRes;
     }
 
     if (av.hasHiddenColumns())
@@ -1175,7 +1178,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
         // Find the next gap before the end
         // of the visible region boundary
         boolean blank = false;
-        for (fixedRight = fixedRight; fixedRight > lastres; fixedRight--)
+        for (; fixedRight > lastres; fixedRight--)
         {
           blank = true;
 
@@ -1871,8 +1874,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     }
     if (copycolsel
             && av.hasHiddenColumns()
-            && (av.getColumnSelection() == null || av.getAlignment()
-                    .getHiddenColumns().getHiddenRegions() == null))
+            && (av.getColumnSelection() == null))
     {
       System.err.println("Bad things");
     }