mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Do not modify CodeStyleSettings of "Default" Code Style Scheme, create copy and modify it instead (IDEA-144408)
This commit is contained in:
+14
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.formatting.contextConfiguration;
|
||||
|
||||
import com.intellij.application.options.codeStyle.CodeStyleSchemesModel;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.lang.Language;
|
||||
@@ -93,7 +94,7 @@ public class ConfigureCodeStyleOnSelectedFragment implements IntentionAction {
|
||||
private final Editor myEditor;
|
||||
private final Document myDocument;
|
||||
private SelectedTextFormatter mySelectedTextFormatter;
|
||||
private final CodeStyleSettings mySettings;
|
||||
private CodeStyleSettings mySettings;
|
||||
|
||||
|
||||
public FragmentCodeStyleSettingsDialog(@NotNull final Editor editor,
|
||||
@@ -159,6 +160,7 @@ public class ConfigureCodeStyleOnSelectedFragment implements IntentionAction {
|
||||
|
||||
private void applyFromUiToSettings() {
|
||||
try {
|
||||
createNewCodeStyleSchemeIfDefault();
|
||||
myTabbedLanguagePanel.apply(mySettings);
|
||||
}
|
||||
catch (ConfigurationException e) {
|
||||
@@ -166,6 +168,17 @@ public class ConfigureCodeStyleOnSelectedFragment implements IntentionAction {
|
||||
}
|
||||
}
|
||||
|
||||
private void createNewCodeStyleSchemeIfDefault() {
|
||||
CodeStyleSchemes schemes = CodeStyleSchemes.getInstance();
|
||||
CodeStyleScheme current = schemes.getCurrentScheme();
|
||||
if (current != null && CodeStyleSchemesModel.cannotBeModified(current)) {
|
||||
CodeStyleScheme newScheme = schemes.createNewScheme(null, current);
|
||||
schemes.addScheme(newScheme);
|
||||
CodeStyleSettingsManager.getInstance(myEditor.getProject()).PREFERRED_PROJECT_CODE_STYLE = newScheme.getName();
|
||||
mySettings = newScheme.getCodeStyleSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doCancelAction() {
|
||||
mySelectedTextFormatter.restoreSelectedText();
|
||||
|
||||
Reference in New Issue
Block a user