From a8e189bdbb33587c4c9cd6f9d5560cfce866edf4 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 7 Nov 2017 15:58:36 +0000 Subject: [PATCH] JAL-2684 JAL-2822 avoid out of bounds exception if edit position is beyond sequence string length --- src/jalview/commands/EditCommand.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/jalview/commands/EditCommand.java b/src/jalview/commands/EditCommand.java index d02dbc3..334f30d 100644 --- a/src/jalview/commands/EditCommand.java +++ b/src/jalview/commands/EditCommand.java @@ -758,9 +758,14 @@ public class EditCommand implements CommandI new String(command.string[i])); int ipos = command.seqs[i].findPosition(start) - command.seqs[i].getStart(); - tmp.append(oldstring.substring(end)); + if (end < oldstring.length()) + { + tmp.append(oldstring.substring(end)); + } command.seqs[i].setSequence(tmp.toString()); - command.string[i] = oldstring.substring(start, end).toCharArray(); + command.string[i] = oldstring + .substring(start, Math.min(end, oldstring.length())) + .toCharArray(); String nogapold = AlignSeq.extractGaps(Comparison.GapChars, new String(command.string[i])); -- 1.7.10.2