Merge branch 'bug/JAL-2920_uniprotvariantfeature' into releases/Release_2_10_4_Branch
[jalview.git] / src / jalview / datamodel / CigarArray.java
index d90b3cd..17e9ea6 100644 (file)
@@ -165,42 +165,25 @@ public class CigarArray extends CigarBase
       int hideEnd;
       int last = start;
 
-      Iterator<int[]> regions = hidden.getBoundedIterator(start, end, true);
+      Iterator<int[]> regions = hidden.getBoundedIterator(start, end);
       while (regions.hasNext())
       {
         region = regions.next();
         hideStart = region[0];
         hideEnd = region[1];
 
-        // edit hidden regions to selection range
-        // TODO possible bug here in original code: if hideEnd==last we continue
-        // but shouldn't this be a single D at start?
-        if (hideStart < last)
+        // truncate region at start if last falls in region
+        if ((hideStart < last) && (hideEnd >= last))
         {
-          if (hideEnd > last)
-          {
-            hideStart = last;
-          }
-          else
-          {
-            continue;
-          }
+          hideStart = last;
         }
 
-        if (hideStart > end)
-        {
-          break;
-        }
-
-        if (hideEnd > end)
+        // truncate region at end if end falls in region
+        if (hideEnd > end) // already checked that hideStart<=end
         {
           hideEnd = end;
         }
 
-        if (hideStart > hideEnd)
-        {
-          break;
-        }
         /**
          * form operations...
          */
@@ -213,7 +196,7 @@ public class CigarArray extends CigarBase
       }
 
       // Final match if necessary.
-      if (last < end)
+      if (last <= end)
       {
         addOperation(CigarArray.M, end - last + 1);
       }