EA-28828 - IOOBE: CharArray.charAt

Corrected pasting at the document start
This commit is contained in:
Denis Zhdanov
2011-07-15 12:02:05 +04:00
parent 9e5beea3e1
commit defd63b8ba
2 changed files with 18 additions and 1 deletions
@@ -156,6 +156,23 @@ class Test {
}
}
}\
'''
doTest(before, toPaste, expected)
}
void testPasteAtDocumentStartColumn() {
def before = '<caret>'
def toPaste =
'''\
class Test {
}\
'''
def expected = '''\
class Test {
}\
'''
doTest(before, toPaste, expected)
}
@@ -383,7 +383,7 @@ public class PasteHandler extends EditorActionHandler {
final int i = CharArrayUtil.shiftBackward(chars, startOffset - 1, " \t");
// Handle situation when pasted block doesn't start new line.
if (chars.charAt(i) != '\n') {
if (i > 0 && chars.charAt(i) != '\n') {
int firstNonWsOffset = CharArrayUtil.shiftForward(chars, firstLineStart, " \t");
if (firstNonWsOffset > firstLineStart) {
CharSequence toInsert = chars.subSequence(firstLineStart, firstNonWsOffset);