X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fcommands%2FEditCommand.java;h=894dc754bbc23298c4fd71ac8f208e1370c82e2e;hb=f7b3f09efa23c9353afee3ad7f57c61ab2560e41;hp=06f59cbadf84719ea5d4943ec745a0700c00e48d;hpb=9cf4a84ed83aee947d2adde33aaebed2e72175b9;p=jalview.git diff --git a/src/jalview/commands/EditCommand.java b/src/jalview/commands/EditCommand.java index 06f59cb..894dc75 100644 --- a/src/jalview/commands/EditCommand.java +++ b/src/jalview/commands/EditCommand.java @@ -776,6 +776,10 @@ public class EditCommand implements CommandI { tmp.append(oldstring.substring(end)); } + // stash end prior to updating the sequence object so we can save it if + // need be. + Range oldstartend = new Range(command.seqs[i].getStart(), + command.seqs[i].getEnd()); command.seqs[i].setSequence(tmp.toString()); command.string[i] = oldstring .substring(start, Math.min(end, oldstring.length())) @@ -785,25 +789,27 @@ public class EditCommand implements CommandI if (!nogaprep.toLowerCase().equals(nogapold.toLowerCase())) { - // probably need a new dataset sequence - if (newDSWasNeeded) + // we may already have dataset and limits stashed... + if (newDSWasNeeded || newStartEndWasNeeded) { + if (newDSWasNeeded) + { // then just switch the dataset sequence SequenceI oldds = command.seqs[i].getDatasetSequence(); command.seqs[i].setDatasetSequence(command.oldds[i]); command.oldds[i] = oldds; - } - else - if (newStartEndWasNeeded) - { - Range newStart = command.oldStartEnd[i]; - command.oldStartEnd[i] = new Range(command.seqs[i].getStart(), - command.seqs[i].getEnd()); - command.seqs[i].setStart(newStart.getBegin()); - command.seqs[i].setEnd(newStart.getEnd()); + } + if (newStartEndWasNeeded) + { + Range newStart = command.oldStartEnd[i]; + command.oldStartEnd[i] = oldstartend; + command.seqs[i].setStart(newStart.getBegin()); + command.seqs[i].setEnd(newStart.getEnd()); + } } else { + // decide if we need a new dataset sequence or modify start/end // first edit the original dataset sequence string SequenceI oldds = command.seqs[i].getDatasetSequence(); String osp = oldds.getSequenceAsString(); @@ -846,7 +852,8 @@ public class EditCommand implements CommandI { // modification at end command.seqs[i].setEnd( - beforeEditedPositions.getEnd() + nogaprep.length()); + beforeEditedPositions.getEnd() + nogaprep.length() + - nogapold.length()); } else if (afterEditedPositions != null && beforeEditedPositions == null)