From e837c31b2c551c8ba670dee4f05583ba20b7f72f Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Fri, 29 Aug 2014 17:16:02 +0400 Subject: [PATCH] java: handle { after if/while statement condition and insert new block statement if needed: wrap with command --- .../codeInsight/editorActions/JavaTypedHandler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaTypedHandler.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaTypedHandler.java index 4905877a9a11..5d2acb275291 100644 --- a/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaTypedHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/JavaTypedHandler.java @@ -19,6 +19,7 @@ import com.intellij.codeInsight.AutoPopupController; import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.completion.JavaClassReferenceCompletionContributor; import com.intellij.codeInsight.editorActions.smartEnter.JavaSmartEnterProcessor; +import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorModificationUtil; @@ -137,7 +138,12 @@ public class JavaTypedHandler extends TypedHandlerDelegate { PsiElement prev = offset > 1 ? file.findElementAt(offset - 1) : null; if (CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET && isRparenth(leaf) && (st instanceof PsiWhileStatement || st instanceof PsiIfStatement) && shouldInsertStatementBody(st, doc, prev)) { - new JavaSmartEnterProcessor().process(project, editor, file); + CommandProcessor.getInstance().executeCommand(project, new Runnable() { + @Override + public void run() { + new JavaSmartEnterProcessor().process(project, editor, file); + } + }, "Insert block statement", null); return Result.STOP; } if (PsiTreeUtil.getParentOfType(leaf, PsiCodeBlock.class, false, PsiMember.class) != null) {