mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
PY-18522 "Smart indent on paste" preserves original indent of statement if necessary
This commit is contained in:
@@ -162,9 +162,11 @@ public class PythonCopyPasteProcessor implements CopyPastePreProcessor {
|
||||
indentText = strings.get(0);
|
||||
}
|
||||
}
|
||||
if (indentText.length() == firstLineIndent)
|
||||
// Top-level, there should be no indentation
|
||||
if (PsiTreeUtil.getParentOfType(ws, PyStatementList.class) == null) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return indentText;
|
||||
}
|
||||
|
||||
|
||||
5
python/testData/copyPaste/SameIndentPreserved.after.py
Normal file
5
python/testData/copyPaste/SameIndentPreserved.after.py
Normal file
@@ -0,0 +1,5 @@
|
||||
def f():
|
||||
x = 1
|
||||
z = 3
|
||||
|
||||
y = 2
|
||||
4
python/testData/copyPaste/SameIndentPreserved.dst.py
Normal file
4
python/testData/copyPaste/SameIndentPreserved.dst.py
Normal file
@@ -0,0 +1,4 @@
|
||||
def f():
|
||||
x = 1
|
||||
<caret>
|
||||
y = 2
|
||||
6
python/testData/copyPaste/SameIndentPreserved.src.py
Normal file
6
python/testData/copyPaste/SameIndentPreserved.src.py
Normal file
@@ -0,0 +1,6 @@
|
||||
def f():
|
||||
x = 1
|
||||
|
||||
y = 2
|
||||
<selection> z = 3
|
||||
</selection>
|
||||
@@ -371,4 +371,9 @@ public class PyCopyPasteTest extends PyTestCase {
|
||||
private void doTestMultiLine() {
|
||||
doTest("multiLine/");
|
||||
}
|
||||
|
||||
// PY-18522
|
||||
public void testSameIndentPreserved() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user