From ff92f374dccd3957f49f8d04e6e0dedf5b3eab6f Mon Sep 17 00:00:00 2001 From: Alexander Doroshko Date: Mon, 16 Oct 2023 20:12:31 +0200 Subject: [PATCH] partial revert of 9a35b941d to restore external formatters functionality (e.g., in LSP-based plugins) IJ-CR-116890 GitOrigin-RevId: ac85db6f9668eeeedb265b2ce48116d6e3e708ac --- .../com/intellij/codeInsight/actions/ReformatCodeAction.java | 4 +++- .../intellij/codeInsight/actions/ShowReformatFileDialog.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java index f645b330de78..1f9598367d4e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java @@ -284,7 +284,9 @@ public class ReformatCodeAction extends AnAction implements DumbAware, LightEdit return false; } - return LanguageFormatting.INSTANCE.forContext(file) != null; + if (LanguageFormatting.INSTANCE.forContext(file) != null) { + return true; + } } else if (files != null && containsOnlyFiles(files)) { boolean anyFormatters = false; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/ShowReformatFileDialog.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/ShowReformatFileDialog.java index e44a8a9c2f8e..265fa90ac6cb 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/ShowReformatFileDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/ShowReformatFileDialog.java @@ -36,7 +36,9 @@ public class ShowReformatFileDialog extends AnAction implements DumbAware { return; } - presentation.setEnabled(LanguageFormatting.INSTANCE.forContext(file) != null); + if (LanguageFormatting.INSTANCE.forContext(file) != null) { + presentation.setEnabled(true); + } } @Override