Fix focus-tab --previous/next to ignore tab switcher order (#10947)

When creating `startupAction` use `TabSwitcherMode::Disabled` in action args
to disable the tab switcher and prevent MRU logic to be applied.

Closes #10070
This commit is contained in:
Don-Vito 2021-08-19 20:18:14 +03:00 committed by GitHub
parent 638c6d0291
commit 46fd7caf5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View file

@ -380,6 +380,11 @@ void AppCommandlineArgs::_buildFocusTabParser()
else if (_focusNextTab || _focusPrevTab)
{
focusTabAction.Action(_focusNextTab ? ShortcutAction::NextTab : ShortcutAction::PrevTab);
// GH#10070 - make sure to not use the MRU order when switching
// tabs on the commandline. That wouldn't make any sense!
focusTabAction.Args(_focusNextTab ?
static_cast<IActionArgs>(NextTabArgs(TabSwitcherMode::Disabled)) :
static_cast<IActionArgs>(PrevTabArgs(TabSwitcherMode::Disabled)));
_startupActions.push_back(std::move(focusTabAction));
}
});

View file

@ -1475,6 +1475,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
struct PrevTabArgs : public PrevTabArgsT<PrevTabArgs>
{
PrevTabArgs() = default;
PrevTabArgs(TabSwitcherMode switcherMode) :
_SwitcherMode(switcherMode) {}
ACTION_ARG(Windows::Foundation::IReference<TabSwitcherMode>, SwitcherMode, nullptr);
static constexpr std::string_view SwitcherModeKey{ "tabSwitcherMode" };
@ -1523,6 +1525,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
struct NextTabArgs : public NextTabArgsT<NextTabArgs>
{
NextTabArgs() = default;
NextTabArgs(TabSwitcherMode switcherMode) :
_SwitcherMode(switcherMode) {}
ACTION_ARG(Windows::Foundation::IReference<TabSwitcherMode>, SwitcherMode, nullptr);
static constexpr std::string_view SwitcherModeKey{ "tabSwitcherMode" };
@ -1772,4 +1776,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation
BASIC_FACTORY(FindMatchArgs);
BASIC_FACTORY(NewWindowArgs);
BASIC_FACTORY(FocusPaneArgs);
BASIC_FACTORY(PrevTabArgs);
BASIC_FACTORY(NextTabArgs);
}

View file

@ -276,11 +276,15 @@ namespace Microsoft.Terminal.Settings.Model
[default_interface] runtimeclass PrevTabArgs : IActionArgs
{
PrevTabArgs();
PrevTabArgs(TabSwitcherMode SwitcherMode);
Windows.Foundation.IReference<TabSwitcherMode> SwitcherMode;
};
[default_interface] runtimeclass NextTabArgs : IActionArgs
{
NextTabArgs();
NextTabArgs(TabSwitcherMode SwitcherMode);
Windows.Foundation.IReference<TabSwitcherMode> SwitcherMode;
};