From 4d660878b2245c0f4035b2e49b50cc19d77051da Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 3 Jan 2012 23:54:25 +0100 Subject: [PATCH] position text cursor at the end of the selection after surrounding with quotes/braces --- .../editorActions/SelectionQuotingTypedHandler.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectionQuotingTypedHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectionQuotingTypedHandler.java index 072eec52866c..528d4844afaf 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectionQuotingTypedHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectionQuotingTypedHandler.java @@ -35,7 +35,6 @@ public class SelectionQuotingTypedHandler extends TypedHandlerDelegate { public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.selectionDequotingFilter"); private TextRange myReplacedTextRange; - private int myCaretPosition; @Override public Result checkAutoPopup(char c, Project project, Editor editor, PsiFile psiFile) { @@ -46,8 +45,6 @@ public class SelectionQuotingTypedHandler extends TypedHandlerDelegate { if (selectedText.length() < 1) { return super.checkAutoPopup(c, project, editor, psiFile); } - myCaretPosition = editor.getCaretModel().getOffset(); - boolean replace = false; if (selectedText.length() > 1) { final char firstChar = selectedText.charAt(0); if (isSimilarDelimiters(firstChar, c) && @@ -56,7 +53,6 @@ public class SelectionQuotingTypedHandler extends TypedHandlerDelegate { !shouldSkipReplacementOfQuotesOrBraces(psiFile, editor, selectedText, c) ) { selectedText = selectedText.substring(1, selectedText.length() - 1); - replace = true; } } final int caretOffset = editor.getSelectionModel().getSelectionStart(); @@ -65,12 +61,6 @@ public class SelectionQuotingTypedHandler extends TypedHandlerDelegate { EditorModificationUtil.insertStringAtCaret(editor, newText); if (Registry.is("editor.smarterSelectionQuoting")) { myReplacedTextRange = new TextRange(caretOffset + 1, caretOffset + newText.length() - 1); - if (!replace || myCaretPosition == caretOffset) { - myCaretPosition++; - } - else if (myCaretPosition == caretOffset + newText.length()) { - myCaretPosition--; - } } else { myReplacedTextRange = new TextRange(caretOffset, caretOffset + newText.length()); } @@ -117,7 +107,7 @@ public class SelectionQuotingTypedHandler extends TypedHandlerDelegate { if (myReplacedTextRange.getEndOffset() <= editor.getDocument().getTextLength()) { editor.getSelectionModel().setSelection(myReplacedTextRange.getStartOffset(), myReplacedTextRange.getEndOffset()); if (Registry.is("editor.smarterSelectionQuoting")) { - editor.getCaretModel().moveToOffset(myCaretPosition); + editor.getCaretModel().moveToOffset(myReplacedTextRange.getEndOffset()); } } myReplacedTextRange = null;