mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-99666 Adding parens in emacs mode causes selected contents to duplicate
This commit is contained in:
+4
-2
@@ -47,11 +47,13 @@ public class SelectionQuotingTypedHandler extends TypedHandlerDelegate {
|
||||
// beforeCharTyped always works with removed selection
|
||||
SelectionModel selectionModel = editor.getSelectionModel();
|
||||
if(CodeInsightSettings.getInstance().SURROUND_SELECTION_ON_QUOTE_TYPED && selectionModel.hasSelection() && isDelimiter(c)) {
|
||||
CaretModel caretModel = editor.getCaretModel();
|
||||
String selectedText = selectionModel.getSelectedText();
|
||||
if (selectedText.length() < 1) {
|
||||
return super.checkAutoPopup(c, project, editor, psiFile);
|
||||
}
|
||||
|
||||
final int selectionStart = selectionModel.getSelectionStart();
|
||||
final int selectionEnd = selectionModel.getSelectionEnd();
|
||||
if (selectedText.length() > 1) {
|
||||
final char firstChar = selectedText.charAt(0);
|
||||
if (isSimilarDelimiters(firstChar, c) &&
|
||||
@@ -73,7 +75,7 @@ public class SelectionQuotingTypedHandler extends TypedHandlerDelegate {
|
||||
myRestoreStickySelection = false;
|
||||
}
|
||||
selectionModel.removeSelection();
|
||||
editor.getDocument().replaceString(caretOffset, caretOffset + selectedText.length(), newText);
|
||||
editor.getDocument().replaceString(selectionStart, selectionEnd, newText);
|
||||
if (Registry.is("editor.smarterSelectionQuoting")) {
|
||||
myReplacedTextRange = new TextRange(caretOffset + 1, caretOffset + newText.length() - 1);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user