From: kiramt Date: Tue, 30 Jan 2018 15:56:59 +0000 (+0000) Subject: JAL-2759 Add missing hiddenColumns empty check X-Git-Tag: Release_2_10_4~55^2~1^2~10 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=476227ce4c2ec7de2232524a5330806c801ca825;p=jalview.git JAL-2759 Add missing hiddenColumns empty check --- diff --git a/src/jalview/datamodel/HiddenColumns.java b/src/jalview/datamodel/HiddenColumns.java index c40c105..17d3fe4 100644 --- a/src/jalview/datamodel/HiddenColumns.java +++ b/src/jalview/datamodel/HiddenColumns.java @@ -682,16 +682,19 @@ public class HiddenColumns { LOCK.readLock().lock(); - int regionindex = cursor.findRegionForColumn(column, false) - .getRegionIndex(); - if (regionindex > -1 && regionindex < hiddenColumns.size()) + if (!hiddenColumns.isEmpty()) { - int[] region = hiddenColumns.get(regionindex); - // already know that column <= region[1] as cursor returns containing - // region or region to right - if (column >= region[0]) + int regionindex = cursor.findRegionForColumn(column, false) + .getRegionIndex(); + if (regionindex > -1 && regionindex < hiddenColumns.size()) { - return false; + int[] region = hiddenColumns.get(regionindex); + // already know that column <= region[1] as cursor returns containing + // region or region to right + if (column >= region[0]) + { + return false; + } } } return true; diff --git a/test/jalview/datamodel/HiddenColumnsTest.java b/test/jalview/datamodel/HiddenColumnsTest.java index e4aa8e2..38536c8 100644 --- a/test/jalview/datamodel/HiddenColumnsTest.java +++ b/test/jalview/datamodel/HiddenColumnsTest.java @@ -456,6 +456,8 @@ public class HiddenColumnsTest public void testIsVisible() { HiddenColumns cs = new HiddenColumns(); + assertTrue(cs.isVisible(5)); + cs.hideColumns(2, 4); cs.hideColumns(6, 7); assertTrue(cs.isVisible(0));