Skip to content

Commit

Permalink
Prevent multiple settings tabs from being persisted (#17169)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zadjii-msft committed May 2, 2024
1 parent 2f52f27 commit a5835b0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/cascadia/TerminalApp/TerminalTab.cpp
Expand Up @@ -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));
}
Expand Down

0 comments on commit a5835b0

Please sign in to comment.