Skip to content

Commit

Permalink
Fix focus-tab --previous/next to ignore tab switcher order (#10947)
Browse files Browse the repository at this point in the history
When creating `startupAction` use `TabSwitcherMode::Disabled` in action args
to disable the tab switcher and prevent MRU logic to be applied.

Closes #10070
  • Loading branch information
Don-Vito authored Aug 19, 2021
1 parent 638c6d0 commit 46fd7ca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cascadia/TerminalApp/AppCommandlineArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
});
Expand Down
6 changes: 6 additions & 0 deletions src/cascadia/TerminalSettingsModel/ActionArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" };

Expand Down Expand Up @@ -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" };

Expand Down Expand Up @@ -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);
}
4 changes: 4 additions & 0 deletions src/cascadia/TerminalSettingsModel/ActionArgs.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit 46fd7ca

Please sign in to comment.