PY-49080 Don't add backslashes to line breaks in patterns containing brackets

GitOrigin-RevId: 43d718f9e470355d92c7bd518fee5991185703f1
This commit is contained in:
Mikhail Golubev
2021-06-17 20:08:02 +00:00
committed by intellij-monorepo-bot
parent 7a75f49ef5
commit 9247e2eb84
20 changed files with 119 additions and 2 deletions
@@ -15,7 +15,11 @@ public final class PyEditorHandlerConfig {
PyDictLiteralExpression.class,
PyParenthesizedExpression.class,
PyArgumentList.class,
PyParameterList.class
PyParameterList.class,
PyGroupPattern.class,
PySequencePattern.class,
PyMappingPattern.class,
PyPatternArgumentList.class,
};
static final Class[] WRAPPABLE_CLASSES = new Class[]{
PsiComment.class,
@@ -31,6 +35,10 @@ public final class PyEditorHandlerConfig {
PyDecoratorList.class,
PySliceExpression.class,
PySubscriptionExpression.class,
PyGeneratorExpression.class
PyGeneratorExpression.class,
PyGroupPattern.class,
PySequencePattern.class,
PyMappingPattern.class,
PyPatternArgumentList.class,
};
}
@@ -0,0 +1,4 @@
match x:
case 'foo' \
'<caret>bar':
pass
@@ -0,0 +1,3 @@
match x:
case 'foo<caret>bar':
pass
@@ -0,0 +1,5 @@
match x:
case Class(
<caret>
):
pass
@@ -0,0 +1,3 @@
match x:
case Class(<caret>):
pass
@@ -0,0 +1,4 @@
match x:
case (42
<caret>):
pass
@@ -0,0 +1,3 @@
match x:
case (42<caret>):
pass
@@ -0,0 +1,4 @@
match x:
case {'foo': 1,
<caret>'bar': 2}
pass
@@ -0,0 +1,3 @@
match x:
case {'foo': 1, <caret>'bar': 2}
pass
@@ -0,0 +1,4 @@
match x:
case [1,
<caret>2]:
pass
@@ -0,0 +1,3 @@
match x:
case [1, <caret>2]:
pass
@@ -0,0 +1,4 @@
match x:
case Class('foo'
'<caret>bar'):
pass
@@ -0,0 +1,3 @@
match x:
case Class('foo<caret>bar'):
pass
@@ -0,0 +1,4 @@
match x:
case ('foo'
'<caret>bar'):
pass
@@ -0,0 +1,3 @@
match x:
case ('foo<caret>bar'):
pass
@@ -0,0 +1,4 @@
match x:
case {'foo'
'<caret>bar': 1}:
pass
@@ -0,0 +1,3 @@
match x:
case {'foo<caret>bar': 1}:
pass
@@ -0,0 +1,4 @@
match x:
case ['foo'
'<caret>bar']:
pass
@@ -0,0 +1,3 @@
match x:
case ['foo<caret>bar']:
pass
@@ -852,6 +852,51 @@ public class PyEditingTest extends PyTestCase {
doTypingTest('\n');
}
// PY-49080
public void testNoBackslashOnEnterInGroupPattern() {
doTypingTest('\n');
}
// PY-49080
public void testNoBackslashOnEnterInClassPattern() {
doTypingTest('\n');
}
// PY-49080
public void testNoBackslashOnEnterInSequencePattern() {
doTypingTest('\n');
}
// PY-49080
public void testNoBackslashOnEnterInMappingPattern() {
doTypingTest('\n');
}
// PY-49080
public void testNoBackslashOnEnterInStringLiteralInsideGroupPattern() {
doTypingTest('\n');
}
// PY-49080
public void testNoBackslashOnEnterInStringLiteralInsideClassPattern() {
doTypingTest('\n');
}
// PY-49080
public void testNoBackslashOnEnterInStringLiteralInsideSequencePattern() {
doTypingTest('\n');
}
// PY-49080
public void testNoBackslashOnEnterInStringLiteralInsideMappingPattern() {
doTypingTest('\n');
}
// PY-49080
public void testBackslashOnEnterInTopLevelStringLiteralPattern() {
doTypingTest('\n');
}
@NotNull
private PyCodeStyleSettings getPythonCodeStyleSettings() {
return getCodeStyleSettings().getCustomSettings(PyCodeStyleSettings.class);