JAL-345 also include any sequences that have highlighted regions
authorJim Procter <jprocter@issues.jalview.org>
Fri, 14 Sep 2018 11:38:41 +0000 (12:38 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Fri, 14 Sep 2018 11:38:41 +0000 (12:38 +0100)
src/jalview/controller/AlignViewController.java

index 13b84ef..e9205f6 100644 (file)
@@ -29,6 +29,7 @@ import jalview.api.FeatureRenderer;
 import jalview.commands.OrderCommand;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SearchResultsI;
 import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceGroup;
@@ -410,19 +411,37 @@ public class AlignViewController implements AlignViewControllerI
                     ? viewport.getSelectionGroup()
                     : new SequenceGroup();
 
+    SearchResultsI searchResults = viewport.getSearchResults();
     if (invert)
     {
       List<SequenceI> nothighlighted = new ArrayList();
       for (SequenceI seq : alignPanel.getAlignViewport().getAlignment()
               .getSequences())
       {
-        if (!results.contains(seq))
+        if (!results.contains(seq) && (searchResults == null
+                || !searchResults.involvesSequence(seq)))
         {
           nothighlighted.add(seq);
         }
       }
       results = nothighlighted;
     }
+    else
+    {
+      // copy list and add in search results
+      results = new ArrayList(results);
+      if (searchResults != null)
+      {
+        for (SequenceI seq : alignPanel.getAlignViewport().getAlignment()
+                .getSequences())
+        {
+          if (searchResults.involvesSequence(seq))
+          {
+            results.add(seq);
+          }
+        }
+      }
+    }
 
     if (results == null || results.size() == 0)
     {