Prevent multiple settings tabs from being persisted (#17169)

Re-add some machinery to special case settings tabs. When we're going to
persist a tab that only has a single settings pane in it, we'll now
promote that to the first-class "openSettings" action. This will allow
our other code in TerminalPage to route multiple settings tabs all to
the same tab.

This of course doesn't stop you from opening multiple settings tabs with
`{ "command": {"action": "newTab", "type": "settings"} }` actions. If we
did that, then that would prevent someone from having a settings pane in
the first pane, and a terminal to the right.

Closes #17070
This commit is contained in:
Mike Griese 2024-05-01 21:11:25 -05:00 committed by GitHub
parent 2f52f27197
commit a5835b01b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -449,9 +449,23 @@ namespace winrt::TerminalApp::implementation
{
ActionAndArgs newTabAction{};
INewContentArgs newContentArgs{ state.firstPane->GetTerminalArgsForPane(kind) };
// Special case here: if there was one pane (which results in no actions
// being generated), and it was a settings pane, then promote that to an
// open settings action. The openSettings action itself has additional machinery
// to prevent multiple top-level settings tabs.
const auto wasSettings = state.args.empty() &&
(newContentArgs && newContentArgs.Type() == L"settings");
if (wasSettings)
{
newTabAction.Action(ShortcutAction::OpenSettings);
newTabAction.Args(OpenSettingsArgs{ SettingsTarget::SettingsUI });
return std::vector<ActionAndArgs>{ std::move(newTabAction) };
}
newTabAction.Action(ShortcutAction::NewTab);
NewTabArgs newTabArgs{ state.firstPane->GetTerminalArgsForPane(kind) };
newTabAction.Args(newTabArgs);
newTabAction.Args(NewTabArgs{ newContentArgs });
state.args.emplace(state.args.begin(), std::move(newTabAction));
}