Skip to content

Commit

Permalink
auto promote the first split to a tab in this scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Jan 20, 2022
1 parent 4275c50 commit ff72599
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,30 @@ namespace winrt::TerminalApp::implementation
std::shared_ptr<Pane> newPane)
{
const auto focusedTab{ _GetFocusedTabImpl() };
_SplitPane(*focusedTab, splitDirection, splitSize, newPane);

// Clever hack for a crash in startup, with multiple sub-commands. Say
// you have the following commandline:
//
// wtd nt -p "elevated cmd" ; sp -p "elevated cmd" ; sp -p "Command Prompt"
//
// Where "elevated cmd" is an elevated profile.
//
// In that scenario, we won't dump off the commandline immediately to an
// elevated window, because it's got the final unelevated split in it.
// However, when we get to that command, there won't be a tab yet. So
// we'd crash right about here.
//
// Instead, let's just promote this first split to be a tab instead.
// Crash avoided, and we don't need to worry about inserting a new-tab
// command in at the start.
if (!focusedTab && _tabs.Size() == 0)
{
_CreateNewTabFromPane(newPane);
}
else
{
_SplitPane(*focusedTab, splitDirection, splitSize, newPane);
}
}

// Method Description:
Expand Down

1 comment on commit ff72599

@github-actions

This comment was marked as resolved.

Please sign in to comment.