mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
PY-15469 Properly place backslashes in various places inside function header
This commit is contained in:
@@ -66,7 +66,7 @@ public class PythonEnterHandler extends EnterHandlerDelegateAdapter {
|
||||
PyListLiteralExpression.class,
|
||||
PyArgumentList.class,
|
||||
PyParameterList.class,
|
||||
PyFunction.class,
|
||||
PyDecoratorList.class,
|
||||
PySliceExpression.class,
|
||||
PySubscriptionExpression.class,
|
||||
PyGeneratorExpression.class
|
||||
@@ -248,7 +248,10 @@ public class PythonEnterHandler extends EnterHandlerDelegateAdapter {
|
||||
if (wrappableBefore instanceof PsiComment || wrappableAfter instanceof PsiComment) {
|
||||
return false;
|
||||
}
|
||||
return wrappableAfter == null || wrappableBefore != wrappableAfter;
|
||||
if (wrappableAfter == null) {
|
||||
return !(wrappableBefore instanceof PyDecoratorList);
|
||||
}
|
||||
return wrappableBefore != wrappableAfter;
|
||||
}
|
||||
|
||||
private static void insertDocStringStub(Editor editor, PsiElement element) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.jetbrains.python.documentation.DocStringFormat;
|
||||
import com.jetbrains.python.documentation.PyDocumentationSettings;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -319,6 +320,48 @@ public class PyEditingTest extends PyTestCase {
|
||||
" ')'");
|
||||
}
|
||||
|
||||
public void testEnterAfterDefKeywordInFunction() {
|
||||
doTestEnter("def <caret>func():\n" +
|
||||
" pass",
|
||||
"def \\\n" +
|
||||
" func():\n" +
|
||||
" pass");
|
||||
}
|
||||
|
||||
public void testEnterBeforeColonInFunction() {
|
||||
doTestEnter("def func()<caret>:\n" +
|
||||
" pass",
|
||||
"def func()\\\n" +
|
||||
" :\n" +
|
||||
" pass");
|
||||
}
|
||||
|
||||
// PY-15469
|
||||
public void testEnterBeforeArrowInFunction() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON30, new Runnable() {
|
||||
public void run() {
|
||||
doTestEnter("def func() <caret>-> int:\n" +
|
||||
" pass",
|
||||
"def func() \\\n" +
|
||||
" -> int:\n" +
|
||||
" pass");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// PY-15469
|
||||
public void testEnterAfterArrowInFunction() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON30, new Runnable() {
|
||||
public void run() {
|
||||
doTestEnter("def func() -><caret> int:\n" +
|
||||
" pass",
|
||||
"def func() ->\\\n" +
|
||||
" int:\n" +
|
||||
" pass");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doTestEnter(String before, final String after) {
|
||||
int pos = before.indexOf("<caret>");
|
||||
before = before.replace("<caret>", "");
|
||||
|
||||
Reference in New Issue
Block a user