JAL-2370 fix bug when hiding a range including two or more hidden ranges
[jalview.git] / src / jalview / datamodel / ColumnSelection.java
index d651c0b..c467f4a 100644 (file)
@@ -866,6 +866,24 @@ public class ColumnSelection
          */
         region[0] = Math.min(region[0], start);
         region[1] = Math.max(region[1], end);
+
+        /*
+         * also update or remove any subsequent ranges 
+         * that are overlapped
+         */
+        while (i < hiddenColumns.size() - 1)
+        {
+          int[] nextRegion = hiddenColumns.get(i + 1);
+          if (nextRegion[0] > end + 1)
+          {
+            /*
+             * gap to next hidden range - no more to update
+             */
+            break;
+          }
+          region[1] = Math.max(nextRegion[1], end);
+          hiddenColumns.remove(i + 1);
+        }
         return;
       }
     }