-
Notifications
You must be signed in to change notification settings - Fork 269
Description
Description
In (at least) Python syntax highlighting, the character after the quote you just closed can be removed/overwritten.

<speculation>
This appears to be caused by the token maker. In the exact same scenario for Java, there will be a token "something with a type of ERROR_STRING_DOUBLE. But for Python, you get a token "something with a type of LITERAL_STRING_DOUBLE_QUOTE. This leads to a different branch in InsertQuoteAction, specifically this one:
if (tokenType == quoteType.validTokenType) {
if (offs == t.getEndOffset() - 1) {
textArea.moveCaretPosition(offs + 1); // Force a replacement to ensure undo is contiguous
textArea.replaceSelection(stringifiedQuoteTypeCh);
textArea.setCaretPosition(offs + 1);
}This seems to be the cause of the issue, with the root being the token type spit out by the token maker.
</speculation>
Steps to Reproduce
- Type a string such as
str("something)into an RSyntaxTextArea with Python syntax highlighting. - Set the caret position between
gand). - Enter a double quote.
Here's a test case that reproduces in RSyntaxTextAreaEditorKitInsertQuoteActionTest:
@Test
void testActionPerformedImpl_python_close_quote_overtypes() {
String origContent = "call(\"function)";
RSyntaxTextArea textArea = createTextArea(SyntaxConstants.SYNTAX_STYLE_PYTHON, origContent);
textArea.setCaretPosition(origContent.indexOf("function") + 8);
RecordableTextAction a = new RSyntaxTextAreaEditorKit.InsertQuoteAction("test",
RSyntaxTextAreaEditorKit.InsertQuoteAction.QuoteType.DOUBLE_QUOTE);
ActionEvent e = createActionEvent(textArea, "\"");
a.actionPerformedImpl(e, textArea);
Assertions.assertEquals("call(\"function\")", textArea.getText());
}Expected behavior
Double quotes should be closed 'correctly' without overtyping.
I'll also note, for the sake of it, that single quotes work just fine.