[by: nicity] IDEA-77340 Incorrect indentation on pasting a method with empty line before (in Indent Block mode)

1. Doc comment is added;
2. Test is added;
This commit is contained in:
Denis.Zhdanov
2011-11-28 19:18:34 +03:00
parent f9e45f27a3
commit a10c9beb07
2 changed files with 51 additions and 2 deletions
@@ -580,7 +580,44 @@ class Test {
'''
doTest(before, toPaste2, expected2)
}
void testPasteMultilineTextThatStartsWithLineFeedToNewLineWithBigCaretIndent() {
def before = '''\
class Test {
void test(int i) {
if (i > 0) {
<caret>
}
}
}\
'''
def toPaste = '''
test(1);
test(1);\
'''
def expected = '''\
class Test {
void test(int i) {
if (i > 0) {
test(1);
test(1);
}
}
}\
'''
doTest(before, toPaste, expected)
def toPaste2 = '''
test(1);
test(1);\
'''
doTest(before, toPaste2, expected)
}
def testPlainTextPaste() {
def before = '''\
line1
@@ -519,7 +519,19 @@ public class PasteHandler extends EditorActionHandler implements EditorTextInser
}
return;
}
// We've pasted text to the non-first column and exact white space between the line start and caret position on the moment of paste
// has been removed by formatter during 'adjust line indent'
// Example:
// copied text:
// ' line1
// line2'
// after paste:
// line start -> ' I line1
// line2' (I - caret position during 'paste')
// formatter removed white space between the line start and caret position, so, current document state is:
// ' line1
// line2'
if (anchorLine == firstLine && -diff == startOffset - firstLineStart) {
return;
}