mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DBE: support surround with function DBE-2534 + ability to keep multicarets
This commit is contained in:
+14
-10
@@ -63,6 +63,7 @@ import java.util.*;
|
||||
public class SurroundWithHandler implements CodeInsightActionHandler {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.generation.surroundWith.SurroundWithHandler");
|
||||
private static final String CHOOSER_TITLE = CodeInsightBundle.message("surround.with.chooser.title");
|
||||
public static final TextRange CARET_IS_OK = new TextRange(0, 0);
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
|
||||
@@ -199,16 +200,19 @@ public class SurroundWithHandler implements CodeInsightActionHandler {
|
||||
editor.getCaretModel().moveToLogicalPosition(pos);
|
||||
}
|
||||
TextRange range = surrounder.surroundElements(project, editor, elements);
|
||||
if (TemplateManager.getInstance(project).getActiveTemplate(editor) == null && InplaceRefactoring.getActiveInplaceRenamer(editor) == null) {
|
||||
LogicalPosition pos1 = new LogicalPosition(line, col);
|
||||
editor.getCaretModel().moveToLogicalPosition(pos1);
|
||||
}
|
||||
if (range != null) {
|
||||
int offset = range.getStartOffset();
|
||||
editor.getCaretModel().removeSecondaryCarets();
|
||||
editor.getCaretModel().moveToOffset(offset);
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
editor.getSelectionModel().setSelection(range.getStartOffset(), range.getEndOffset());
|
||||
if (range != CARET_IS_OK) {
|
||||
if (TemplateManager.getInstance(project).getActiveTemplate(editor) == null &&
|
||||
InplaceRefactoring.getActiveInplaceRenamer(editor) == null) {
|
||||
LogicalPosition pos1 = new LogicalPosition(line, col);
|
||||
editor.getCaretModel().moveToLogicalPosition(pos1);
|
||||
}
|
||||
if (range != null) {
|
||||
int offset = range.getStartOffset();
|
||||
editor.getCaretModel().removeSecondaryCarets();
|
||||
editor.getCaretModel().moveToOffset(offset);
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
editor.getSelectionModel().setSelection(range.getStartOffset(), range.getEndOffset());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
|
||||
Reference in New Issue
Block a user