mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
duplicate action: preserve caret position when it's already inside element's name
This commit is contained in:
@@ -35,7 +35,6 @@ xxx<caret>
|
||||
private void doTest(String before, @NonNls String ext, String after) {
|
||||
myFixture.configureByText("a." + ext, before);
|
||||
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_DUPLICATE)
|
||||
println "/" + myFixture.editor.document.text.substring(myFixture.editor.caretModel.offset) + "/"
|
||||
myFixture.checkResult(after);
|
||||
}
|
||||
|
||||
@@ -52,6 +51,19 @@ class C {
|
||||
'''
|
||||
}
|
||||
|
||||
public void "test preserve caret position when it's already inside element's name"() {
|
||||
doTest '''
|
||||
class C {
|
||||
void fo<caret>o() {}
|
||||
}
|
||||
''', 'java', '''
|
||||
class C {
|
||||
void foo() {}
|
||||
void fo<caret>o() {}
|
||||
}
|
||||
'''
|
||||
}
|
||||
|
||||
public void testXmlTag() {
|
||||
doTest '''
|
||||
<root>
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class NamedElementDuplicateHandler extends EditorWriteActionHandler {
|
||||
TextRange toDuplicate = new TextRange(editor.logicalPositionToOffset(lines.first), editor.logicalPositionToOffset(lines.second));
|
||||
|
||||
PsiElement name = findNameIdentifier(editor, file, toDuplicate);
|
||||
if (name != null) {
|
||||
if (name != null && !name.getTextRange().containsOffset(editor.getCaretModel().getOffset())) {
|
||||
editor.getCaretModel().moveToOffset(name.getTextOffset());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user