From eadd0616ac0efd1ba8be47828e0905fe07a9eb12 Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Tue, 31 Jan 2017 15:36:33 +0300 Subject: [PATCH] Apply settings to model without preview too (cherry picked from commit 397e9d9) --- .../options/CodeStyleAbstractPanel.java | 23 ++++++++++++------- .../options/GeneralCodeStylePanel.java | 1 - 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java b/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java index e8cbca68fa21..2a862a81aeac 100644 --- a/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/CodeStyleAbstractPanel.java @@ -210,14 +210,7 @@ public abstract class CodeStyleAbstractPanel implements Disposable { PsiFile psiFile = createFileFromText(project, myTextToReformat); prepareForReformat(psiFile); - try { - apply(mySettings); - if (myModel != null) { - myModel.fireAfterCurrentSettingsChanged(); - } - } - catch (ConfigurationException ignore) { - } + applySettingsToModel(); CodeStyleSettings clone = mySettings.clone(); clone.setRightMargin(getDefaultLanguage(), getAdjustedRightMargin()); CodeStyleSettingsManager.getInstance(project).setTemporarySettings(clone); @@ -242,6 +235,17 @@ public abstract class CodeStyleAbstractPanel implements Disposable { }); } + private void applySettingsToModel() { + try { + apply(mySettings); + if (myModel != null) { + myModel.fireAfterCurrentSettingsChanged(); + } + } + catch (ConfigurationException ignore) { + } + } + /** * Reformats {@link #myTextToReformat target text} with the {@link #mySettings current code style settings} and returns * list of changes applied to the target text during that. @@ -444,6 +448,9 @@ public abstract class CodeStyleAbstractPanel implements Disposable { UiNotifyConnector.doWhenFirstShown(myEditor.getComponent(), () -> addUpdatePreviewRequest()); } } + else { + applySettingsToModel(); + } } private void addUpdatePreviewRequest() { diff --git a/platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java b/platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java index 8562731d2dad..463f88e67858 100644 --- a/platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/GeneralCodeStylePanel.java @@ -223,7 +223,6 @@ public class GeneralCodeStylePanel extends CodeStyleAbstractPanel { private static String getTagText(JTextField field, String defaultValue) { String fieldText = field.getText(); if (StringUtil.isEmpty(field.getText())) { - field.setText(defaultValue); return defaultValue; } return fieldText;