-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix saving naming styles options page #34212
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,9 @@ internal abstract class AbstractOptionPage : UIElementDialogPage | |
{ | ||
private static IOptionService s_optionService; | ||
private static OptionStore s_optionStore; | ||
private static bool s_needsLoadOnNextActivate = true; | ||
private static bool s_needsToUpdateOptionStore = true; | ||
|
||
private bool _needsLoadOnNextActivate = true; | ||
|
||
protected abstract AbstractOptionPageControl CreateOptionPage(IServiceProvider serviceProvider, OptionStore optionStore); | ||
|
||
|
@@ -50,16 +52,22 @@ protected override void OnActivate(System.ComponentModel.CancelEventArgs e) | |
{ | ||
EnsureOptionPageCreated(); | ||
|
||
if (s_needsLoadOnNextActivate) | ||
if (s_needsToUpdateOptionStore) | ||
{ | ||
// Reset the option store to the current state of the options. | ||
s_optionStore.SetOptions(s_optionService.GetOptions()); | ||
s_optionStore.SetRegisteredOptions(s_optionService.GetRegisteredOptions()); | ||
|
||
s_needsLoadOnNextActivate = false; | ||
s_needsToUpdateOptionStore = false; | ||
} | ||
|
||
pageControl.LoadSettings(); | ||
if (_needsLoadOnNextActivate) | ||
{ | ||
// For pages that don't use option bindings we need to load setting changes. | ||
pageControl.OnLoad(); | ||
|
||
_needsLoadOnNextActivate = false; | ||
} | ||
} | ||
|
||
public override void LoadSettingsFromStorage() | ||
|
@@ -81,19 +89,36 @@ public override void LoadSettingsFromStorage() | |
// they may have been changed programmatically. Therefore, we'll set a flag so we load | ||
// next time | ||
|
||
s_needsLoadOnNextActivate = pageControl != null; | ||
// When pageControl is null we know that Activation has not happened for this page. | ||
// We only need to update the OptionStore after a cancel or close click (2). | ||
s_needsToUpdateOptionStore = pageControl != null; | ||
|
||
// For pages that don't use option bindings we need to load settings when it is | ||
// activated next. | ||
_needsLoadOnNextActivate = true; | ||
} | ||
|
||
public override void SaveSettingsToStorage() | ||
{ | ||
EnsureOptionPageCreated(); | ||
|
||
// Allow page controls to perist their settings to the option store before updating the | ||
// option service. | ||
pageControl.OnSave(); | ||
|
||
// Save the changes that were accumulated in the option store. | ||
s_optionService.SetOptions(s_optionStore.GetOptions()); | ||
var oldOptions = s_optionService.GetOptions(); | ||
var newOptions = s_optionStore.GetOptions(); | ||
s_optionService.SetOptions(newOptions); | ||
OptionLogger.Log(oldOptions, newOptions); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As pointed out by David offline, we had been logging option changes on SaveSettings before the earlier PR moved logging into the OptionStore. This reverts the behavior back. |
||
|
||
// Make sure we load the next time a page is activated, in case that options changed | ||
// programmatically between now and the next time the page is activated | ||
s_needsLoadOnNextActivate = true; | ||
s_needsToUpdateOptionStore = true; | ||
|
||
// For pages that don't use option bindings we need to load settings when it is | ||
// activated next. | ||
_needsLoadOnNextActivate = true; | ||
} | ||
|
||
protected override void OnClosed(EventArgs e) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated to the fix, but allows for builds in VS to not fail. This same change is already in the master branch.