PY-32918 Handle enter in f-string right before the closing quote

in the context where we don't need to insert additional backslashes.
This commit is contained in:
Mikhail Golubev
2018-12-17 19:25:42 +03:00
parent 1393e2593f
commit 01643844e1
2 changed files with 8 additions and 1 deletions
@@ -135,7 +135,8 @@ public class PythonEnterHandler extends EnterHandlerDelegateAdapter {
if (stringElement != null && (!stringElement.isFormatted() ||
nodeType == PyTokenTypes.FSTRING_TEXT ||
// Caret should be right before the opening brace of an f-string fragment
nodeType == PyTokenTypes.FSTRING_FRAGMENT_START)) {
nodeType == PyTokenTypes.FSTRING_FRAGMENT_START ||
nodeType == PyTokenTypes.FSTRING_END)) {
if (stringElement.isTripleQuoted() || nodeType == PyTokenTypes.DOCSTRING) {
return Result.Continue;
}
@@ -126,6 +126,12 @@ public class PyEditingTest extends PyTestCase {
" f'{42}bar'");
}
// PY-32918
public void testEnterInFStringRightBeforeClosingQuote() {
doTestEnter("(f'foo{42}bar<caret>')", "(f'foo{42}bar'\n" +
" f'')");
}
public void testOvertypeFromInside() {
assertEquals("''", doTestTyping("''", 1, '\''));
}