mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-13868 Move statement on a comment inside a dict deletes the dict
This commit is contained in:
+5
-5
@@ -119,10 +119,6 @@ public class PyStatementMover extends LineMover {
|
||||
final int startLine = document.getLineNumber(start);
|
||||
final int endLine = document.getLineNumber(end);
|
||||
|
||||
if (elementToMove instanceof PsiComment && destination instanceof PsiComment) {
|
||||
return new LineRange(lineNumber, lineNumber + 1);
|
||||
}
|
||||
|
||||
if (elementToMove instanceof PyClass || elementToMove instanceof PyFunction) {
|
||||
PyElement scope = statementList == null ? (PyElement)elementToMove.getContainingFile() : statementList;
|
||||
if (destination != null)
|
||||
@@ -137,6 +133,11 @@ public class PyStatementMover extends LineMover {
|
||||
scopeRange = moveInto(elementToMove, file, editor, down, lineEndOffset);
|
||||
if (scopeRange != null) return scopeRange;
|
||||
|
||||
if (elementToMove instanceof PsiComment && ( PsiTreeUtil.isAncestor(destination, elementToMove, true)) ||
|
||||
destination instanceof PsiComment) {
|
||||
return new LineRange(lineNumber, lineNumber + 1);
|
||||
}
|
||||
|
||||
final PyElement scope = statementList == null ? (PyElement)elementToMove.getContainingFile() : statementList;
|
||||
if ((elementToMove instanceof PyClass) || (elementToMove instanceof PyFunction))
|
||||
return new ScopeRange(scope, scope.getFirstChild(), !down, true);
|
||||
@@ -185,7 +186,6 @@ public class PyStatementMover extends LineMover {
|
||||
|
||||
if (sibling != null) {
|
||||
final PyStatementList list = sibling.getStatementList();
|
||||
assert list != null;
|
||||
return new ScopeRange(list, down ? list.getFirstChild() : list.getLastChild(), !addBefore);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
a = {
|
||||
1:1,
|
||||
# te<caret>st
|
||||
2:2
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
a = {
|
||||
1:1,
|
||||
2:2
|
||||
# te<caret>st
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
a = {
|
||||
# te<caret>st
|
||||
1:1,
|
||||
2:2
|
||||
}
|
||||
@@ -260,6 +260,10 @@ public class PyStatementMoverTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testOutsideFromDict() { //PY-11595
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testWith() { // PY-5202
|
||||
try {
|
||||
setLanguageLevel(LanguageLevel.PYTHON27);
|
||||
|
||||
Reference in New Issue
Block a user