diff --git a/python/src/com/jetbrains/python/lexer/PythonIndentingProcessor.java b/python/src/com/jetbrains/python/lexer/PythonIndentingProcessor.java index 13db518df37a..64ff8bd561b4 100644 --- a/python/src/com/jetbrains/python/lexer/PythonIndentingProcessor.java +++ b/python/src/com/jetbrains/python/lexer/PythonIndentingProcessor.java @@ -111,6 +111,11 @@ public class PythonIndentingProcessor extends MergingLexerAdapter { return super.getTokenEnd(); } + @NotNull + private String getBaseTokenText() { + return getBufferSequence().subSequence(getBaseTokenStart(), getBaseTokenEnd()).toString(); + } + private boolean isBaseAt(IElementType tokenType) { return getBaseTokenType() == tokenType; } @@ -189,10 +194,12 @@ public class PythonIndentingProcessor extends MergingLexerAdapter { } private void checkFString() { - final String tokenText = getTokenText(); + final String tokenText = getBaseTokenText(); if (isBaseAt(PyTokenTypes.FSTRING_START)) { final int prefixLength = PyStringLiteralUtil.getPrefixLength(tokenText); - myFStringStack.push(tokenText.substring(prefixLength)); + final String openingQuotes = tokenText.substring(prefixLength); + assert !openingQuotes.isEmpty(); + myFStringStack.push(openingQuotes); } else if (isBaseAt(PyTokenTypes.FSTRING_END)) { while (!myFStringStack.isEmpty()) { diff --git a/python/testSrc/com/jetbrains/python/PythonParsingTest.java b/python/testSrc/com/jetbrains/python/PythonParsingTest.java index 58db6e4f35b6..b5607db4fed2 100644 --- a/python/testSrc/com/jetbrains/python/PythonParsingTest.java +++ b/python/testSrc/com/jetbrains/python/PythonParsingTest.java @@ -725,6 +725,10 @@ public class PythonParsingTest extends ParsingTestCase { doTest(LanguageLevel.PYTHON36); } + public void testMultilineFStringContainingMultilineExpressionAfterStatementBreak() { + doTest(LanguageLevel.PYTHON36); + } + public void testNestedMultilineFStringsWithMultilineExpressions() { doTest(LanguageLevel.PYTHON36); }