Skip to content
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

Add support for restoring non-terminal panes, and opening them with splitPane, newTab #16914

Merged
merged 115 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
f353323
I wanted to do this in one shot but _zelda_
zadjii-msft May 12, 2023
4e14442
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Jul 17, 2023
ef6bb8a
hey look, it builds now
zadjii-msft Jul 17, 2023
5b3aa54
move GetNewTerminalArgs into IPaneContent
zadjii-msft Jul 17, 2023
84df819
close event
zadjii-msft Jul 17, 2023
7c9ffb0
snapping now uses an interface, so that it's not TermControl-specific
zadjii-msft Jul 18, 2023
a1da6c1
huge shuffling so that pane content can raise events instead of relyi…
zadjii-msft Jul 18, 2023
049c043
some last cleanups
zadjii-msft Jul 18, 2023
2dd8f40
[TO PARENT] dead code
zadjii-msft Jul 18, 2023
1b39db7
Single commit that adds the whole scratchpad and action
zadjii-msft Jul 18, 2023
63ba8e1
[PARENT] You know what, I just went for it.
zadjii-msft Jul 18, 2023
262d95a
[PARENT] try to use GetActiveTerminalControl less in TerminalTab
zadjii-msft Jul 18, 2023
2d40306
Let's just make it experimental
zadjii-msft Jul 18, 2023
e6dc314
Merge commit 'b4042ea' into dev/migrie/fhl/non-terminal-panes-2023
zadjii-msft Jul 19, 2023
e31202b
Merge commit '6a10ea5' into dev/migrie/fhl/non-terminal-panes-2023
zadjii-msft Jul 20, 2023
11126f9
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Jul 20, 2023
5f9add4
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Jul 20, 2023
a23c1a2
keybindings too
zadjii-msft Jul 20, 2023
5582e1b
[PARENT] You know what, I just went for it.
zadjii-msft Jul 18, 2023
f89368c
[PARENT] try to use GetActiveTerminalControl less in TerminalTab
zadjii-msft Jul 18, 2023
e0b003a
Merge branch 'main' into dev/migrie/fhl/non-terminal-panes-2023
zadjii-msft Jul 24, 2023
86914bd
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Jul 25, 2023
1cc9835
feature flags too
zadjii-msft Jul 27, 2023
cbd61b0
POC: yea, this works
zadjii-msft Jul 27, 2023
29d0d57
this works better than it has any right to
zadjii-msft Jul 27, 2023
fb7c809
derp
zadjii-msft Aug 1, 2023
842326d
icons for non-terminal pane content
zadjii-msft Aug 3, 2023
521e301
update settings should work now
zadjii-msft Aug 3, 2023
9531069
background brush, done
zadjii-msft Aug 7, 2023
c869b47
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Sep 11, 2023
46469aa
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Sep 11, 2023
6107c3e
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Sep 11, 2023
2086e0f
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Oct 13, 2023
b49997b
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Oct 13, 2023
57e1f26
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Oct 13, 2023
d726165
terrible, but it works
zadjii-msft Oct 13, 2023
e82c627
dead code removal
zadjii-msft Oct 13, 2023
81889a6
derp
zadjii-msft Oct 13, 2023
5f4087f
finish exorcising SettingsTab
zadjii-msft Oct 13, 2023
fb74fc8
dead code
zadjii-msft Oct 13, 2023
fd06409
annoying build break
zadjii-msft Oct 13, 2023
8df9523
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Oct 25, 2023
58e8f3c
mostly nits
zadjii-msft Oct 25, 2023
e9e04d4
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Oct 25, 2023
7bc1457
nits and such
zadjii-msft Oct 25, 2023
dd8606f
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Oct 25, 2023
389ba20
spel
zadjii-msft Oct 25, 2023
cf920e7
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Nov 2, 2023
4cec7e9
try to remove a few of these but ultimately, eh
zadjii-msft Nov 6, 2023
f622d80
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Nov 8, 2023
6bc711d
maybe I'm not that good at coding
zadjii-msft Nov 8, 2023
0d528f8
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Jan 19, 2024
3982358
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Feb 8, 2024
c244633
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Feb 8, 2024
092b355
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Feb 8, 2024
de5f7af
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Feb 28, 2024
25a8851
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Feb 28, 2024
17075d6
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Feb 28, 2024
0a11643
sanely pass around a cache instead of... whatever that was.
zadjii-msft Mar 4, 2024
4d47cd5
cleanup
zadjii-msft Mar 4, 2024
b6254f8
GREAT-GRANDPARENT: This fixes a crash in parent pane selection
zadjii-msft Mar 7, 2024
a3fbc64
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Mar 8, 2024
35651bc
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Mar 8, 2024
978fd6e
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Mar 8, 2024
ef775a8
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Mar 18, 2024
524d658
GREAT-GREAT-GRANDPARENT: Hey when a pane wants to get closed, we shou…
zadjii-msft Mar 15, 2024
1951f30
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Mar 18, 2024
863840e
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Mar 18, 2024
ecc036a
Start just one file at a time
zadjii-msft Mar 19, 2024
6789ec0
some of the easier nits
zadjii-msft Mar 19, 2024
fd8b083
get rid of this file
zadjii-msft Mar 19, 2024
052dc78
more nits
zadjii-msft Mar 19, 2024
a7533fa
eh these events are from pane content anyways!
zadjii-msft Mar 19, 2024
826fc08
hey there buddy, did you get lost?
zadjii-msft Mar 19, 2024
52970ef
RegisterBigTimeEncapsulationViolatingTerminalPaneContentEvents
zadjii-msft Mar 19, 2024
2357653
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Mar 20, 2024
c8d0c0a
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Mar 20, 2024
e0bb840
Fix scratch pane for merge
zadjii-msft Mar 20, 2024
352e0a2
fix settings pane for merge
zadjii-msft Mar 20, 2024
bcceb85
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Mar 20, 2024
e08149e
Merge branch 'dev/migrie/f/sui-panes' into dev/migrie/f/992-content-args
zadjii-msft Mar 20, 2024
40a3408
hey it compiles?
zadjii-msft Mar 20, 2024
ea9522a
hey it runs... but it crashes
zadjii-msft Mar 20, 2024
18fe0d8
stashing, but I think this builds
zadjii-msft Mar 20, 2024
8a37c52
this just works, amazing
zadjii-msft Mar 21, 2024
3ae152f
would you look at that? the tests caught something!
zadjii-msft Mar 21, 2024
2083b2f
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Mar 21, 2024
f1ab16e
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Mar 21, 2024
77022e9
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Mar 21, 2024
7a631f2
Merge branch 'dev/migrie/f/sui-panes' into dev/migrie/f/992-content-args
zadjii-msft Mar 21, 2024
df73d75
derp
zadjii-msft Mar 21, 2024
d417934
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Mar 21, 2024
216cc3f
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Mar 21, 2024
251cfab
Merge branch 'dev/migrie/f/sui-panes' into dev/migrie/f/992-content-args
zadjii-msft Mar 21, 2024
61e952c
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Mar 26, 2024
0979cd6
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Mar 26, 2024
b6e4b62
Doesn't really need to be projected
zadjii-msft Mar 26, 2024
1d20599
un fix this file
zadjii-msft Mar 26, 2024
ddc88c8
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Mar 26, 2024
10e1e46
ALSO doesn't really need to be projected
zadjii-msft Mar 26, 2024
7243d22
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/scratc…
zadjii-msft Mar 26, 2024
ef560bf
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
zadjii-msft Mar 26, 2024
e05b2bb
Merge branch 'main' into dev/migrie/f/sui-panes
zadjii-msft Mar 29, 2024
a0e014f
Merge remote-tracking branch 'origin/main' into dev/migrie/f/sui-panes
zadjii-msft Apr 3, 2024
7c4dfff
Merge remote-tracking branch 'origin/main' into dev/migrie/f/sui-panes
zadjii-msft Apr 3, 2024
96b2d07
Merge branch 'dev/migrie/f/sui-panes' into dev/migrie/f/992-content-args
zadjii-msft Apr 3, 2024
07562d5
nits
zadjii-msft Apr 3, 2024
893b25e
this is contrived
zadjii-msft Apr 4, 2024
df04c07
Revert "this is contrived"
zadjii-msft Apr 4, 2024
3d48ef4
fix some broken tests
zadjii-msft Apr 4, 2024
e5ebbb0
god VS just save the file
zadjii-msft Apr 4, 2024
162eb83
fixes #16914
zadjii-msft Apr 4, 2024
309e6a7
nits
zadjii-msft Apr 5, 2024
2fa4266
weaks
zadjii-msft Apr 5, 2024
2c2dad0
Merge remote-tracking branch 'origin/main' into dev/migrie/f/992-cont…
zadjii-msft Apr 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
593 changes: 320 additions & 273 deletions src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp

Large diffs are not rendered by default.

508 changes: 271 additions & 237 deletions src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp

Large diffs are not rendered by default.

91 changes: 61 additions & 30 deletions src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,32 @@ namespace winrt::TerminalApp::implementation
}
}

// * Helper to try and get a ProfileIndex out of a NewTerminalArgs out of a
// NewContentArgs. For the new tab and split pane action, we want to _not_
// handle the event if an invalid profile index was passed.
//
// Return value:
// * True if the args are NewTerminalArgs, and the profile index was out of bounds.
// * False otherwise.
static bool _shouldBailForInvalidProfileIndex(const CascadiaSettings& settings, const INewContentArgs& args)
{
if (!args)
{
return false;
}
if (const auto& terminalArgs{ args.try_as<NewTerminalArgs>() })
{
if (const auto index = terminalArgs.ProfileIndex())
{
if (gsl::narrow<uint32_t>(index.Value()) >= settings.ActiveProfiles().Size())
{
return true;
}
}
}
return false;
}

void TerminalPage::_HandleSplitPane(const IInspectable& sender,
const ActionEventArgs& args)
{
Expand All @@ -247,16 +273,10 @@ namespace winrt::TerminalApp::implementation
}
else if (const auto& realArgs = args.ActionArgs().try_as<SplitPaneArgs>())
{
if (const auto& newTerminalArgs{ realArgs.TerminalArgs() })
if (_shouldBailForInvalidProfileIndex(_settings, realArgs.ContentArgs()))
{
if (const auto index = realArgs.TerminalArgs().ProfileIndex())
{
if (gsl::narrow<uint32_t>(index.Value()) >= _settings.ActiveProfiles().Size())
{
args.Handled(false);
return;
}
}
args.Handled(false);
return;
}

const auto& duplicateFromTab{ realArgs.SplitMode() == SplitType::Duplicate ? _GetFocusedTab() : nullptr };
Expand All @@ -267,7 +287,7 @@ namespace winrt::TerminalApp::implementation
realArgs.SplitDirection(),
// This is safe, we're already filtering so the value is (0, 1)
::base::saturated_cast<float>(realArgs.SplitSize()),
_MakePane(realArgs.TerminalArgs(), duplicateFromTab));
_MakePane(realArgs.ContentArgs(), duplicateFromTab));
args.Handled(true);
}
}
Expand Down Expand Up @@ -445,19 +465,13 @@ namespace winrt::TerminalApp::implementation
}
else if (const auto& realArgs = args.ActionArgs().try_as<NewTabArgs>())
{
if (const auto& newTerminalArgs{ realArgs.TerminalArgs() })
if (_shouldBailForInvalidProfileIndex(_settings, realArgs.ContentArgs()))
{
if (const auto index = newTerminalArgs.ProfileIndex())
{
if (gsl::narrow<uint32_t>(index.Value()) >= _settings.ActiveProfiles().Size())
{
args.Handled(false);
return;
}
}
args.Handled(false);
return;
}

LOG_IF_FAILED(_OpenNewTab(realArgs.TerminalArgs()));
LOG_IF_FAILED(_OpenNewTab(realArgs.ContentArgs()));
args.Handled(true);
}
}
Expand Down Expand Up @@ -869,8 +883,23 @@ namespace winrt::TerminalApp::implementation
// - <none>
// Important: Don't take the param by reference, since we'll be doing work
// on another thread.
fire_and_forget TerminalPage::_OpenNewWindow(const NewTerminalArgs newTerminalArgs)
fire_and_forget TerminalPage::_OpenNewWindow(const INewContentArgs newContentArgs)
{
auto terminalArgs{ newContentArgs.try_as<NewTerminalArgs>() };

// Do nothing for non-terminal panes.
//
// Theoretically, we could define a `IHasCommandline` interface, and
// stick `ToCommandline` on that interface, for any kind of pane that
// wants to be convertable to a wt commandline.
//
// Another idea we're thinking about is just `wt do {literal json for an
// action}`, which might be less leaky
if (terminalArgs == nullptr)
{
co_return;
}

// Hop to the BG thread
co_await winrt::resume_background();

Expand All @@ -883,8 +912,7 @@ namespace winrt::TerminalApp::implementation
// `-w -1` will ensure a new window is created.
winrt::hstring cmdline{
fmt::format(L"-w -1 new-tab {}",
newTerminalArgs ? newTerminalArgs.ToCommandline().c_str() :
L"")
terminalArgs.ToCommandline().c_str())
};

// Build the args to ShellExecuteEx. We need to use ShellExecuteEx so we
Expand All @@ -909,29 +937,32 @@ namespace winrt::TerminalApp::implementation
void TerminalPage::_HandleNewWindow(const IInspectable& /*sender*/,
const ActionEventArgs& actionArgs)
{
NewTerminalArgs newTerminalArgs{ nullptr };
INewContentArgs newContentArgs{ nullptr };
// If the caller provided NewTerminalArgs, then try to use those
if (actionArgs)
{
if (const auto& realArgs = actionArgs.ActionArgs().try_as<NewWindowArgs>())
{
newTerminalArgs = realArgs.TerminalArgs();
newContentArgs = realArgs.ContentArgs();
}
}
// Otherwise, if no NewTerminalArgs were provided, then just use a
// default-constructed one. The default-constructed one implies that
// nothing about the launch should be modified (just use the default
// profile).
if (!newTerminalArgs)
if (!newContentArgs)
{
newTerminalArgs = NewTerminalArgs();
newContentArgs = NewTerminalArgs{};
}

const auto profile{ _settings.GetProfileForArgs(newTerminalArgs) };
if (const auto& terminalArgs{ newContentArgs.try_as<NewTerminalArgs>() })
{
const auto profile{ _settings.GetProfileForArgs(terminalArgs) };
terminalArgs.Profile(::Microsoft::Console::Utils::GuidToString(profile.Guid()));
}

// Manually fill in the evaluated profile.
newTerminalArgs.Profile(::Microsoft::Console::Utils::GuidToString(profile.Guid()));
_OpenNewWindow(newTerminalArgs);
_OpenNewWindow(newContentArgs);
actionArgs.Handled(true);
}

Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/IPaneContent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace TerminalApp
Windows.Foundation.IReference<Windows.UI.Color> TabColor { get; };
Windows.UI.Xaml.Media.Brush BackgroundBrush { get; };

Microsoft.Terminal.Settings.Model.NewTerminalArgs GetNewTerminalArgs(BuildStartupKind kind);
Microsoft.Terminal.Settings.Model.INewContentArgs GetNewTerminalArgs(BuildStartupKind kind);

void Focus(Windows.UI.Xaml.FocusState reason);

Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Pane::Pane(std::shared_ptr<Pane> first,

// Extract the terminal settings from the current (leaf) pane's control
// to be used to create an equivalent control
NewTerminalArgs Pane::GetTerminalArgsForPane(BuildStartupKind kind) const
INewContentArgs Pane::GetTerminalArgsForPane(BuildStartupKind kind) const
{
// Leaves are the only things that have controls
assert(_IsLeaf());
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/Pane.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Pane : public std::enable_shared_from_this<Pane>
uint32_t panesCreated;
};
BuildStartupState BuildStartupActions(uint32_t currentId, uint32_t nextId, winrt::TerminalApp::BuildStartupKind kind);
winrt::Microsoft::Terminal::Settings::Model::NewTerminalArgs GetTerminalArgsForPane(winrt::TerminalApp::BuildStartupKind kind) const;
winrt::Microsoft::Terminal::Settings::Model::INewContentArgs GetTerminalArgsForPane(winrt::TerminalApp::BuildStartupKind kind) const;

void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
bool ResizePane(const winrt::Microsoft::Terminal::Settings::Model::ResizeDirection& direction);
Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/ScratchpadContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ namespace winrt::TerminalApp::implementation
CloseRequested.raise(*this, nullptr);
}

NewTerminalArgs ScratchpadContent::GetNewTerminalArgs(const BuildStartupKind /* kind */) const
INewContentArgs ScratchpadContent::GetNewTerminalArgs(const BuildStartupKind /* kind */) const
{
return nullptr;
return BaseContentArgs(L"scratchpad");
}

winrt::hstring ScratchpadContent::Icon() const
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/ScratchpadContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace winrt::TerminalApp::implementation

void Focus(winrt::Windows::UI::Xaml::FocusState reason = winrt::Windows::UI::Xaml::FocusState::Programmatic);
void Close();
winrt::Microsoft::Terminal::Settings::Model::NewTerminalArgs GetNewTerminalArgs(BuildStartupKind kind) const;
winrt::Microsoft::Terminal::Settings::Model::INewContentArgs GetNewTerminalArgs(BuildStartupKind kind) const;

winrt::hstring Title() { return L"Scratchpad"; }
uint64_t TaskbarState() { return 0; }
Expand Down
7 changes: 2 additions & 5 deletions src/cascadia/TerminalApp/SettingsPaneContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,9 @@ namespace winrt::TerminalApp::implementation
CloseRequested.raise(*this, nullptr);
}

NewTerminalArgs SettingsPaneContent::GetNewTerminalArgs(const BuildStartupKind /*kind*/) const
INewContentArgs SettingsPaneContent::GetNewTerminalArgs(const BuildStartupKind /*kind*/) const
{
// For now, we're doing a terrible thing in TerminalTab itself to
// generate an OpenSettings action manually, without asking for the pane
// structure.
return nullptr;
return BaseContentArgs(L"settings");
}

winrt::hstring SettingsPaneContent::Icon() const
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/SettingsPaneContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace winrt::TerminalApp::implementation
winrt::Windows::Foundation::Size MinimumSize();
void Focus(winrt::Windows::UI::Xaml::FocusState reason = winrt::Windows::UI::Xaml::FocusState::Programmatic);
void Close();
winrt::Microsoft::Terminal::Settings::Model::NewTerminalArgs GetNewTerminalArgs(const BuildStartupKind kind) const;
winrt::Microsoft::Terminal::Settings::Model::INewContentArgs GetNewTerminalArgs(const BuildStartupKind kind) const;

winrt::hstring Title() { return RS_(L"SettingsTab"); }
uint64_t TaskbarState() { return 0; }
Expand Down
37 changes: 20 additions & 17 deletions src/cascadia/TerminalApp/TabManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,33 @@ namespace winrt::TerminalApp::implementation
// - existingConnection: An optional connection that is already established to a PTY
// for this tab to host instead of creating one.
// If not defined, the tab will create the connection.
HRESULT TerminalPage::_OpenNewTab(const NewTerminalArgs& newTerminalArgs)
HRESULT TerminalPage::_OpenNewTab(const INewContentArgs& newContentArgs)
try
{
const auto profile{ _settings.GetProfileForArgs(newTerminalArgs) };
// GH#11114: GetProfileForArgs can return null if the index is higher
// than the number of available profiles.
if (!profile)
if (const auto& newTerminalArgs{ newContentArgs.try_as<NewTerminalArgs>() })
{
return S_FALSE;
}
const auto settings{ TerminalSettings::CreateWithNewTerminalArgs(_settings, newTerminalArgs, *_bindings) };
const auto profile{ _settings.GetProfileForArgs(newTerminalArgs) };
// GH#11114: GetProfileForArgs can return null if the index is higher
// than the number of available profiles.
if (!profile)
{
return S_FALSE;
}
const auto settings{ TerminalSettings::CreateWithNewTerminalArgs(_settings, newTerminalArgs, *_bindings) };

// Try to handle auto-elevation
if (_maybeElevate(newTerminalArgs, settings, profile))
{
return S_OK;
// Try to handle auto-elevation
if (_maybeElevate(newTerminalArgs, settings, profile))
{
return S_OK;
}
// We can't go in the other direction (elevated->unelevated)
// unfortunately. This seems to be due to Centennial quirks. It works
// unpackaged, but not packaged.
}
// We can't go in the other direction (elevated->unelevated)
// unfortunately. This seems to be due to Centennial quirks. It works
// unpackaged, but not packaged.
//

// This call to _MakePane won't return nullptr, we already checked that
// case above with the _maybeElevate call.
_CreateNewTabFromPane(_MakePane(newTerminalArgs, nullptr));
_CreateNewTabFromPane(_MakePane(newContentArgs, nullptr));
return S_OK;
}
CATCH_RETURN();
Expand Down
Loading
Loading