mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
[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:
+38
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user