diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingOptionsContainer.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingOptionsContainer.cs index f3bc043736..aa6d771b30 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingOptionsContainer.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/FormattingStrategy/CSharpFormattingOptionsContainer.cs @@ -127,7 +127,7 @@ namespace CSharpBinding.FormattingStrategy if ((e.PropertyName == "Parent") || (e.PropertyName == null)) { // All properties might have changed -> update everything cachedOptions = CreateCachedOptions(); - OnPropertyChanged(e.PropertyName); +// OnPropertyChanged(e.PropertyName); } else { // Some other property has changed, check if we have our own value for it if (!activeOptions.Contains(e.PropertyName)) { @@ -136,7 +136,7 @@ namespace CSharpBinding.FormattingStrategy if (propertyInfo != null) { var val = GetEffectiveOption(e.PropertyName); propertyInfo.SetValue(cachedOptions, val); - OnPropertyChanged(e.PropertyName); +// OnPropertyChanged(e.PropertyName); } } } @@ -265,14 +265,16 @@ namespace CSharpBinding.FormattingStrategy if (parentProperties == null) throw new ArgumentNullException("parentProperties"); - Properties formatProperties = parentProperties.NestedProperties("CSharpFormatting"); - if (formatProperties != null) { - foreach (var key in formatProperties.Keys) { - try { - object val = formatProperties.Get(key, (object) null); - SetOption(key, val); - } catch (Exception) { - // Silently ignore loading error, then this property will be "as parent" automatically + if (parentProperties.Contains("CSharpFormatting")) { + Properties formatProperties = parentProperties.NestedProperties("CSharpFormatting"); + if (formatProperties != null) { + foreach (var key in formatProperties.Keys) { + try { + object val = formatProperties.Get(key, (object)null); + SetOption(key, val); + } catch (Exception) { + // Silently ignore loading error, then this property will be "as parent" automatically + } } } } diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingOptionPanel.xaml.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingOptionPanel.xaml.cs index 56df385daa..059947fa99 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingOptionPanel.xaml.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/CSharpFormattingOptionPanel.xaml.cs @@ -64,6 +64,7 @@ namespace CSharpBinding.OptionPanels internal partial class CSharpFormattingOptionPanel : OptionPanel { readonly CSharpFormattingOptionsPersistence persistenceHelper; + bool isDirty; public CSharpFormattingOptionPanel(CSharpFormattingOptionsPersistence persistenceHelper, bool allowPresets) { @@ -71,6 +72,7 @@ namespace CSharpBinding.OptionPanels throw new ArgumentNullException("persistenceHelper"); this.persistenceHelper = persistenceHelper; + this.isDirty = false; InitializeComponent(); formattingEditor.AllowPresets = allowPresets; @@ -79,12 +81,18 @@ namespace CSharpBinding.OptionPanels public override void LoadOptions() { base.LoadOptions(); - formattingEditor.OptionsContainer = persistenceHelper.StartEditing(); + formattingEditor.OptionsContainer = persistenceHelper.StartEditing(); + formattingEditor.OptionsContainer.PropertyChanged += (sender, e) => isDirty = true; } public override bool SaveOptions() { - return persistenceHelper.Save() && base.SaveOptions(); + if (isDirty) { + return persistenceHelper.Save() && base.SaveOptions(); + } else { + // Nothing has been changed here, return without action + return true; + } } } } \ No newline at end of file