From b65ed30fd44279fd3fb550d12831040ffe55bdb9 Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Fri, 29 Apr 2016 19:01:14 +0300 Subject: [PATCH] Do not allow to reformat code before commit in dumb mode, since formatter implementations could use indices and produce IndexNotReadyException --- .../openapi/vcs/checkin/ReformatBeforeCheckinHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/checkin/ReformatBeforeCheckinHandler.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/checkin/ReformatBeforeCheckinHandler.java index 73b15eab4099..94c06e0765d6 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/checkin/ReformatBeforeCheckinHandler.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/checkin/ReformatBeforeCheckinHandler.java @@ -18,6 +18,7 @@ package com.intellij.openapi.vcs.checkin; import com.intellij.codeInsight.actions.ReformatCodeProcessor; import com.intellij.openapi.fileEditor.FileDocumentManager; +import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.CheckinProjectPanel; import com.intellij.openapi.vcs.VcsBundle; @@ -46,7 +47,7 @@ public class ReformatBeforeCheckinHandler extends CheckinHandler implements Chec @Nullable public RefreshableOnComponent getBeforeCheckinConfigurationPanel() { final JCheckBox reformatBox = new NonFocusableCheckBox(VcsBundle.message("checkbox.checkin.options.reformat.code")); - + CheckinHandlerUtil.disableWhenDumb(myProject, reformatBox, "Impossible until indices are up-to-date"); return new RefreshableOnComponent() { @Override public JComponent getComponent() { @@ -89,7 +90,7 @@ public class ReformatBeforeCheckinHandler extends CheckinHandler implements Chec } }; - if (reformat(configuration, true)) { + if (reformat(configuration, true) && !DumbService.isDumb(myProject)) { new ReformatCodeProcessor( myProject, CheckinHandlerUtil.getPsiFiles(myProject, files), FormatterUtil.REFORMAT_BEFORE_COMMIT_COMMAND_NAME, performCheckoutAction, true ).run();