Skip to content

Commit

Permalink
:chef_kiss:
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Mar 25, 2021
1 parent fe5f3ab commit 330a8e8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3398,7 +3398,9 @@ namespace winrt::TerminalApp::implementation
if (const auto scheme = _settings.GlobalSettings().ColorSchemes().TryLookup(args.SchemeName()))
{
// Get the settings of the focused control and stash them
_originalSettings = activeControl.Settings().as<TerminalSettings>();
auto controlSettings = activeControl.Settings().as<TerminalSettings>();

_originalSettings = controlSettings.GetParent();
// Create a new child for those settings
// auto childImpl = _originalSettings.CreateChild();
TerminalSettingsStruct fake{ _originalSettings, nullptr };
Expand All @@ -3408,7 +3410,7 @@ namespace winrt::TerminalApp::implementation
childStruct.DefaultSettings().ApplyColorScheme(scheme);

// Insert that new child as the parent of the control's settings
activeControl.Settings().as<TerminalSettings>().SetParent(childStruct.DefaultSettings());
controlSettings.SetParent(childStruct.DefaultSettings());
activeControl.UpdateSettings();
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/cascadia/TerminalSettingsModel/TerminalSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
InsertParent(parentImpl);
}

Model::TerminalSettings TerminalSettings::GetParent()
{
if (_parents.size() > 0)
{
return *_parents.at(0);
}
return nullptr;
}

// Method Description:
// - Apply Profile settings, as well as any colors from our color scheme, if we have one.
// Arguments:
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsModel/TerminalSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
const Control::IKeyBindings& keybindings);

static Model::TerminalSettingsStruct CreateWithParent(const Model::TerminalSettingsStruct& parent);
Model::TerminalSettings GetParent();
void SetParent(const Model::TerminalSettings& parent);

void ApplyColorScheme(const Model::ColorScheme& scheme);
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsModel/TerminalSettings.idl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace Microsoft.Terminal.Settings.Model
static TerminalSettingsStruct CreateWithParent(TerminalSettingsStruct parent);

void SetParent(TerminalSettings parent);
TerminalSettings GetParent();
void ApplyColorScheme(ColorScheme scheme);
};
}

0 comments on commit 330a8e8

Please sign in to comment.