You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Renaming a color scheme used by a profile should properly update the profile #8756
Have a profile ("Profile A") refer to a custom color scheme ("Color Scheme A")
Go to the Color Schemes page
Select "Color Scheme A"
Rename it to something else ("Color Scheme B")
Navigate back to the profile that referred to this color scheme ("Profile A")
Expected behavior
"Profile A" should now reference "Color Scheme B".
Actual behavior
"Profile A" refers to "Campbell"
Additional details
The TerminalSettingsModel stores Profile.ColorScheme as a string reference to the name of the ColorScheme.
In TerminalSettingsEditor (Profiles.cpp), if a ColorScheme with that name isn't found, we fallback to "Campbell".
Perhaps a better architecture would be to reference a ColorScheme object in the TerminalSettingsModel? Or at least reference a ColorScheme object in the ViewModel in TerminalSettingsEditor.
So, I'm conflicted. There's the "brute-force" approach and the "elegant" way to do this:
brute-force approach:
When rename is accepted, iterate over all profiles and if profile.ColorSchemeName() == oldName, update the profile w/ profile.ColorSchemeName(newName).
elegant approach:
Idea: use ColorScheme references so that renaming a ColorScheme automatically updates whoever references it
Implementation:
ProfileViewModel holds a reference to a ColorScheme object (the one that the String ColorSchemeName refers to)
(the hard/annoying part) Since ColorScheme.Name() is not observable, we need to create a ColorSchemeViewModel to wrap each ColorScheme, which makes Name observable.
On a NameChanged event, ProfileViewModel would update Profile.ColorSchemeName
Concerns:
As I was writing this, I realized that that won't work either. We're creating the ProfileViewModel as we're navigating to the profile page. So the reference to the ColorScheme object would be created after the rename operation was completed.
To get around that issue, we would have to wrap all of the settings model objects with their respective view model objects when the Settings UI is opened.
Dustin L. Howett (@DHowett) I'm going with the brute-force approach right now. Not too happy with it but it'll at least fix the bug for now. We should discuss what the overall architecture should look like, then file an issue to perform the refactor.
Activity
carlos-zamora commentedon Jan 14, 2021
So, I'm conflicted. There's the "brute-force" approach and the "elegant" way to do this:
profile.ColorSchemeName() == oldName, update the profile w/profile.ColorSchemeName(newName).ColorSchemereferences so that renaming aColorSchemeautomatically updates whoever references itProfileViewModelholds a reference to aColorSchemeobject (the one that theString ColorSchemeNamerefers to)ColorScheme.Name()is not observable, we need to create aColorSchemeViewModelto wrap eachColorScheme, which makesNameobservable.NameChangedevent,ProfileViewModelwould updateProfile.ColorSchemeNameProfileViewModelas we're navigating to the profile page. So the reference to theColorSchemeobject would be created after the rename operation was completed.Dustin L. Howett (@DHowett) I'm going with the brute-force approach right now. Not too happy with it but it'll at least fix the bug for now. We should discuss what the overall architecture should look like, then file an issue to perform the refactor.
Bugfix: sync color scheme rename with profile reference (#8793)
Bugfix: sync color scheme rename with profile reference (microsoft#8793)