JAL-2541 Cut ops always stash the old dataset sequence reference so can be restored...
authorJim Procter <jprocter@issues.jalview.org>
Tue, 24 Oct 2017 14:08:57 +0000 (15:08 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 24 Oct 2017 14:08:57 +0000 (15:08 +0100)
src/jalview/commands/EditCommand.java

index 2d27f4b..4c2f8e7 100644 (file)
@@ -541,21 +541,22 @@ public class EditCommand implements CommandI
 
         if (command.oldds != null && command.oldds[i] != null)
         {
-          // oldds entry contains the cut dataset sequence.
+          // Undoing previous Paste - so
+          // oldds entry contains the cut dataset sequence,
+          // with sequence features in expected place.
           sequence.setDatasetSequence(command.oldds[i]);
           command.oldds[i] = oldds;
         }
         else
         {
-          // modify the oldds if necessary
-          if (oldds != sequence.getDatasetSequence()
-                  || sequence.getFeatures().hasFeatures())
+          // New cut operation
+          // We always keep track of the dataset sequence so we can safely
+          // restore it during the Undo
+          if (command.oldds == null)
           {
-            if (command.oldds == null)
-            {
-              command.oldds = new SequenceI[command.seqs.length];
-            }
-            command.oldds[i] = oldds;
+            command.oldds = new SequenceI[command.seqs.length];
+          }
+          command.oldds[i] = oldds;
 
             if (cutPositions != null)
             {