diff --git a/python/src/com/jetbrains/python/editor/BaseQuoteHandler.java b/python/src/com/jetbrains/python/editor/BaseQuoteHandler.java index fb21ab0ec60c..86e89630cc84 100644 --- a/python/src/com/jetbrains/python/editor/BaseQuoteHandler.java +++ b/python/src/com/jetbrains/python/editor/BaseQuoteHandler.java @@ -88,15 +88,11 @@ public class BaseQuoteHandler extends SimpleTokenSetQuoteHandler implements Mult } private static int getLiteralStartOffset(CharSequence text, int start) { - char c = Character.toUpperCase(text.charAt(start)); - if (c == 'U' || c == 'B') { - start++; - c = Character.toUpperCase(text.charAt(start)); + int index = start; + while (index < start + 2 && "URBF".indexOf(Character.toUpperCase(text.charAt(index))) >= 0) { + index++; } - if (c == 'R') { - start++; - } - return start; + return index; } @Override diff --git a/python/testSrc/com/jetbrains/python/PyEditingTest.java b/python/testSrc/com/jetbrains/python/PyEditingTest.java index ea9caf885adb..7a790dd32886 100644 --- a/python/testSrc/com/jetbrains/python/PyEditingTest.java +++ b/python/testSrc/com/jetbrains/python/PyEditingTest.java @@ -87,6 +87,14 @@ public class PyEditingTest extends PyTestCase { assertEquals("'''docstring'''", doTestTyping("'''docstring''", 14, '\'')); } + // PY-18972 + public void testFString() throws Exception { + assertEquals("f''", doTestTyping("f", 1, '\'')); + assertEquals("rf''", doTestTyping("rf", 2, '\'')); + assertEquals("fr''", doTestTyping("fr", 2, '\'')); + assertEquals("fr''''''", doTestTyping("fr''", 4, '\'')); + } + public void testOvertypeFromInside() { assertEquals("''", doTestTyping("''", 1, '\'')); }