mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-31442 Properly complete triple quotes in f-strings
This commit is contained in:
@@ -22,7 +22,8 @@ import com.jetbrains.python.PyTokenTypes;
|
||||
* @author traff
|
||||
*/
|
||||
public class PythonQuoteHandler extends BaseQuoteHandler {
|
||||
private static final TokenSet APPLICABLE_TOKENS = TokenSet.orSet(PyTokenTypes.STRING_NODES, TokenSet.create(PyTokenTypes.FSTRING_START));
|
||||
private static final TokenSet APPLICABLE_TOKENS = TokenSet.orSet(PyTokenTypes.STRING_NODES,
|
||||
TokenSet.create(PyTokenTypes.FSTRING_START, PyTokenTypes.FSTRING_END));
|
||||
|
||||
public PythonQuoteHandler() {
|
||||
super(APPLICABLE_TOKENS, new char[]{'}', ']', ')', ',', ':', ';', ' ', '\t', '\n'});
|
||||
|
||||
@@ -96,6 +96,7 @@ public class PyEditingTest extends PyTestCase {
|
||||
assertEquals("rf''", doTestTyping("rf", 2, '\''));
|
||||
assertEquals("fr''", doTestTyping("fr", 2, '\''));
|
||||
assertEquals("fr''''''", doTestTyping("fr''", 4, '\''));
|
||||
assertEquals("fr''''''", doTestTyping("fr''", 3, "''"));
|
||||
}
|
||||
|
||||
public void testFStringFragmentBraces() {
|
||||
@@ -505,6 +506,13 @@ public class PyEditingTest extends PyTestCase {
|
||||
return myFixture.getDocument(file).getText();
|
||||
}
|
||||
|
||||
private String doTestTyping(final String text, final int offset, final String characters) {
|
||||
final PsiFile file = myFixture.configureByText(PythonFileType.INSTANCE, text);
|
||||
myFixture.getEditor().getCaretModel().moveToOffset(offset);
|
||||
myFixture.type(characters);
|
||||
return myFixture.getDocument(file).getText();
|
||||
}
|
||||
|
||||
private void doTypingTest(final char character) {
|
||||
final String testName = "editing/" + getTestName(true);
|
||||
myFixture.configureByFile(testName + ".py");
|
||||
|
||||
Reference in New Issue
Block a user