mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-142439 Wrong cursor placement when creating a class after brackets autocomplete
This commit is contained in:
+5
-1
@@ -309,7 +309,11 @@ public class JavaSmartEnterProcessor extends SmartEnterProcessor {
|
||||
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(file.getProject());
|
||||
final boolean old = settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE;
|
||||
settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false;
|
||||
PsiElement elt = PsiTreeUtil.getParentOfType(file.findElementAt(caretOffset - 1), PsiCodeBlock.class);
|
||||
PsiElement leaf = file.findElementAt(caretOffset - 1);
|
||||
PsiElement elt = PsiTreeUtil.getParentOfType(leaf, PsiCodeBlock.class);
|
||||
if (elt == null && leaf != null && leaf.getParent() instanceof PsiClass) {
|
||||
elt = leaf.getParent();
|
||||
}
|
||||
reformat(elt);
|
||||
settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = old;
|
||||
editor.getCaretModel().moveToOffset(caretOffset - 1);
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class MissingClassBodyFixer implements Fixer {
|
||||
|
||||
if (psiClass.getLBrace() == null) {
|
||||
int offset = psiClass.getTextRange().getEndOffset();
|
||||
editor.getDocument().insertString(offset, " {\n}");
|
||||
editor.getDocument().insertString(offset, "{\n}");
|
||||
editor.getCaretModel().moveToOffset(offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class Test
|
||||
{
|
||||
class Foo<caret>
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Test
|
||||
{
|
||||
class Foo
|
||||
{
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
@@ -232,7 +232,11 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
public void testIDEA25139() throws Exception {
|
||||
doTestBracesNextLineStyle();
|
||||
}
|
||||
|
||||
|
||||
public void testClassBracesNextLine() throws Exception {
|
||||
doTestBracesNextLineStyle();
|
||||
}
|
||||
|
||||
public void testBeforeIfRBrace() throws Exception {
|
||||
CodeStyleSettingsManager.getSettings(getProject()).KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user