-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Move TerminalSettings from TermApp to TerminalSettingsModel #9318
Changes from 1 commit
cae4ec7
1e968fd
187a510
fc26768
e2fb1e7
0eaf930
3de9894
1321d76
f3ac13a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -732,7 +732,8 @@ namespace winrt::TerminalApp::implementation | |
void TerminalPage::_OpenNewTab(const NewTerminalArgs& newTerminalArgs) | ||
try | ||
{ | ||
auto [profileGuid, settings] = TerminalSettings::BuildSettings(_settings, newTerminalArgs, *_bindings); | ||
const auto profileGuid{ _settings.GetProfileForArgs(newTerminalArgs) }; | ||
const auto settings{ TerminalSettings::BuildSettings(_settings, newTerminalArgs, *_bindings) }; | ||
|
||
_CreateNewTabFromSettings(profileGuid, settings); | ||
|
||
|
@@ -776,7 +777,7 @@ namespace winrt::TerminalApp::implementation | |
// currently displayed, it will be shown. | ||
// Arguments: | ||
// - settings: the TerminalSettings object to use to create the TerminalControl with. | ||
void TerminalPage::_CreateNewTabFromSettings(GUID profileGuid, TerminalApp::TerminalSettings settings) | ||
void TerminalPage::_CreateNewTabFromSettings(GUID profileGuid, TerminalSettings settings) | ||
{ | ||
// Initialize the new tab | ||
|
||
|
@@ -799,7 +800,7 @@ namespace winrt::TerminalApp::implementation | |
|
||
// Give term control a child of the settings so that any overrides go in the child | ||
// This way, when we do a settings reload we just update the parent and the overrides remain | ||
TermControl term{ *(winrt::get_self<TerminalSettings>(settings)->CreateChild()), connection }; | ||
TermControl term{ settings.MakeChild(), connection }; | ||
carlos-zamora marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
auto newTabImpl = winrt::make_self<TerminalTab>(profileGuid, term); | ||
|
||
|
@@ -882,7 +883,7 @@ namespace winrt::TerminalApp::implementation | |
|
||
if (debugConnection) // this will only be set if global debugging is on and tap is active | ||
{ | ||
TermControl newControl{ *(winrt::get_self<TerminalSettings>(settings)->CreateChild()), debugConnection }; | ||
TermControl newControl{ settings.MakeChild(), debugConnection }; | ||
_RegisterTerminalEvents(newControl, *newTabImpl); | ||
// Split (auto) with the debug tap. | ||
newTabImpl->SplitPane(SplitState::Automatic, 0.5f, profileGuid, newControl); | ||
|
@@ -901,7 +902,7 @@ namespace winrt::TerminalApp::implementation | |
// Return value: | ||
// - the desired connection | ||
TerminalConnection::ITerminalConnection TerminalPage::_CreateConnectionFromSettings(GUID profileGuid, | ||
TerminalApp::TerminalSettings settings) | ||
TerminalSettings settings) | ||
{ | ||
const auto profile = _settings.FindProfile(profileGuid); | ||
|
||
|
@@ -1250,7 +1251,7 @@ namespace winrt::TerminalApp::implementation | |
const auto& profileGuid = terminalTab->GetFocusedProfile(); | ||
if (profileGuid.has_value()) | ||
{ | ||
const auto settings{ winrt::make<TerminalSettings>(_settings, profileGuid.value(), *_bindings) }; | ||
const TerminalSettings settings{ _settings, profileGuid.value(), *_bindings }; | ||
const auto workingDirectory = terminalTab->GetActiveTerminalControl().WorkingDirectory(); | ||
const auto validWorkingDirectory = !workingDirectory.empty(); | ||
if (validWorkingDirectory) | ||
|
@@ -1810,7 +1811,7 @@ namespace winrt::TerminalApp::implementation | |
|
||
try | ||
{ | ||
TerminalApp::TerminalSettings controlSettings; | ||
TerminalSettings controlSettings; | ||
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. This constructs an empty 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. Looks like it isn't. I've changed it to This should've been happening before though so the change shouldn't do anything (other than avoiding the construction of an unused TerminalSettings). Right? 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. Be very, very sure none of the control flows below this initialization relied on it not being null. I can imagine a world where the conditionals fail but then we initialize a terminal with the "default settings". 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. So here's all the possibilities:
We could rewrite this to be more like this? // NOTE: we could
const auto current_guid{ focusedTab->GetFocusedProfile() };
if (splitMode == SplitType::Duplicate && current_guid)
{
// set realGuid and controlSettings
// update working directory
}
else
{
// set realGuid and controlSettings
} That way it would be more clear that we're always setting 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 long as it is provable that there is no codepath that tries to initialize with a null settings, I am okay accepting this. |
||
GUID realGuid; | ||
bool profileFound = false; | ||
|
||
|
@@ -1820,7 +1821,7 @@ namespace winrt::TerminalApp::implementation | |
if (current_guid) | ||
{ | ||
profileFound = true; | ||
controlSettings = { winrt::make<TerminalSettings>(_settings, current_guid.value(), *_bindings) }; | ||
controlSettings = { _settings, current_guid.value(), *_bindings }; | ||
const auto workingDirectory = focusedTab->GetActiveTerminalControl().WorkingDirectory(); | ||
const auto validWorkingDirectory = !workingDirectory.empty(); | ||
if (validWorkingDirectory) | ||
|
@@ -1844,7 +1845,8 @@ namespace winrt::TerminalApp::implementation | |
} | ||
if (!profileFound) | ||
{ | ||
std::tie(realGuid, controlSettings) = TerminalSettings::BuildSettings(_settings, newTerminalArgs, *_bindings); | ||
realGuid = _settings.GetProfileForArgs(newTerminalArgs); | ||
controlSettings = TerminalSettings::BuildSettings(_settings, newTerminalArgs, *_bindings); | ||
} | ||
|
||
const auto controlConnection = _CreateConnectionFromSettings(realGuid, controlSettings); | ||
|
@@ -1865,7 +1867,7 @@ namespace winrt::TerminalApp::implementation | |
return; | ||
} | ||
|
||
TermControl newControl{ *(winrt::get_self<TerminalSettings>(controlSettings)->CreateChild()), controlConnection }; | ||
TermControl newControl{ controlSettings.MakeChild(), controlConnection }; | ||
|
||
// Hookup our event handlers to the new terminal | ||
_RegisterTerminalEvents(newControl, *focusedTab); | ||
|
@@ -2519,7 +2521,7 @@ namespace winrt::TerminalApp::implementation | |
{ | ||
// This can throw an exception if the profileGuid does | ||
// not belong to an actual profile in the list of profiles. | ||
auto settings{ winrt::make<TerminalSettings>(_settings, profileGuid, *_bindings) }; | ||
TerminalSettings settings{ _settings, profileGuid, *_bindings }; | ||
|
||
for (auto tab : _tabs) | ||
{ | ||
|
This file was deleted.
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.
wow crazy how many times we were actually using the guid in the return value of this function too. Shame WinRT won't let us return the pair. Shame.
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.
I really don't love that this responsibility moved into TSM but ok.