JAL-4134 fix off-by-one in selection
authorJames Procter <j.procter@dundee.ac.uk>
Mon, 20 Mar 2023 15:28:52 +0000 (15:28 +0000)
committerJames Procter <j.procter@dundee.ac.uk>
Mon, 20 Mar 2023 15:28:52 +0000 (15:28 +0000)
src/jalview/gui/TreeCanvas.java

index cae2f31..7af8940 100755 (executable)
@@ -1079,15 +1079,15 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
       ColumnSelection cs = av.getColumnSelection();
       HiddenColumns hc = av.getAlignment().getHiddenColumns();
       {
-        int offp = (rseq!=null) ? rseq.findIndex(rseq.getStart()-1+colm) : colm;
+        int offp = (rseq!=null) ? rseq.findIndex(rseq.getStart()+colm) : colm;
         
-        if (!av.hasHiddenColumns() || hc.isVisible(offp))
+        if (!av.hasHiddenColumns() || hc.isVisible(offp-1))
         { 
-          if (cs.contains(offp))
+          if (cs.contains(offp-1))
           {
-            cs.removeElement(offp);
+            cs.removeElement(offp-1);
           } else {
-            cs.addElement(offp);
+            cs.addElement(offp-1);
           }
         }
       }