From 476227ce4c2ec7de2232524a5330806c801ca825 Mon Sep 17 00:00:00 2001 From: kiramt Date: Tue, 30 Jan 2018 15:56:59 +0000 Subject: [PATCH] JAL-2759 Add missing hiddenColumns empty check --- src/jalview/datamodel/HiddenColumns.java | 19 +++++++++++-------- test/jalview/datamodel/HiddenColumnsTest.java | 2 ++ 2 files changed, 13 insertions(+), 8 deletions(-) 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)); -- 1.7.10.2