mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-18972 Automatically close quotes for f-string literals
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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, '\''));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user