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

Display ATS tabs in MRU order #7952

Merged
7 commits merged into from
Oct 21, 2020
Merged

Display ATS tabs in MRU order #7952

7 commits merged into from
Oct 21, 2020

Conversation

leonMSFT
Copy link
Contributor

@leonMSFT leonMSFT commented Oct 16, 2020

This PR changes the ATS display order to always be in most recently
used (MRU) order. I chose not to give ATS the option to be displayed
in-order because that order is better served through the traditional
left-right TabRow switching.

Note: TabSearch will stay in-order.

This means that users can only choose one order or another in their
nextTab/prevTab bindings. Setting useTabSwitcher to true will make
nT/pT open the ATS in MRU order. If it's set to false, the ATS won't
open and nT/pT will simply go left and right on the TabRow.

I'm open to getting rid of the global and making ATS its own keybinding,
but for now I figured I would keep the current behavior and open the PR
to get eyes on the code that doesn't have anything to do with the
settings.

Closes #973

@ghost ghost added Area-Settings Issues related to settings and customizability, for console or terminal Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal. labels Oct 16, 2020
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if we re-order the tabs? Won't we not update the indicies in _mruTabActions, causing the MRU order to be reflective only of the positions the tabs were in, not the actual tabs themselves?

src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
@@ -672,6 +666,7 @@ namespace winrt::TerminalApp::implementation
// Add the new tab to the list of our tabs.
auto newTabImpl = winrt::make_self<Tab>(profileGuid, term);
_tabs.Append(*newTabImpl);
_mruTabActions.Append(newTabImpl->SwitchToTabCommand());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this line necessary? Won't the new tab be appended automatically in _UpdatedSelectedTab?

I suppose it doesn't really matter. The redundancy is nice, especially if we ever have a way to open new tabs without automatically switching to them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda thought of _UpdatedSelectedTab as the function that does things when a Tab is focused, so it assumes that the Tab already exists in the list when it's called. That's why for MRU, _UpdatedSelectedTab doesn't append a new tab, it drags and drops the focused tab to the top of MRU. Then the adding of a new Tab/SwitchToTabCommand should be done by CreateNewTabFromSettings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay that's fine.

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 21, 2020
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 21, 2020
@leonMSFT
Copy link
Contributor Author

I make a call to update the indices of Tab::SwitchToTabCommand whenever there's a rearrange/close/open, so it actually works perfectly fine 😄

@leonMSFT leonMSFT assigned zadjii-msft and unassigned leonMSFT Oct 21, 2020
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I see how it works now. Thanks for clarifying!

@@ -672,6 +666,7 @@ namespace winrt::TerminalApp::implementation
// Add the new tab to the list of our tabs.
auto newTabImpl = winrt::make_self<Tab>(profileGuid, term);
_tabs.Append(*newTabImpl);
_mruTabActions.Append(newTabImpl->SwitchToTabCommand());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay that's fine.

@zadjii-msft zadjii-msft removed their assignment Oct 21, 2020
@zadjii-msft zadjii-msft added the Needs-Second It's a PR that needs another sign-off label Oct 21, 2020
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elegant!

@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 21, 2020
@ghost
Copy link

ghost commented Oct 21, 2020

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 00f5fba into master Oct 21, 2020
@ghost ghost deleted the dev/lelian/mru branch October 21, 2020 19:37
DHowett pushed a commit that referenced this pull request Oct 27, 2020
This PR changes the ATS display order to _always_ be in most recently
used (MRU) order. I chose not to give ATS the option to be displayed
in-order because that order is better served through the traditional
left-right TabRow switching.

_Note_: `TabSearch` will stay in-order.

This means that users can only choose one order or another in their
`nextTab/prevTab` bindings. Setting `useTabSwitcher` to true will make
nT/pT open the ATS in MRU order. If it's set to false, the ATS won't
open and nT/pT will simply go left and right on the TabRow.

I'm open to getting rid of the global and making ATS its own keybinding,
but for now I figured I would keep the current behavior and open the PR
to get eyes on the code that doesn't have anything to do with the
settings.

Closes #973

(cherry picked from commit 00f5fba)
ghost pushed a commit that referenced this pull request Nov 5, 2020
…8076)

## Summary of the Pull Request

Changes the way the `useTabSwitcher` setting works. It now accepts either a boolean or a string:
* `true`, `"mru"`: Use the tab switcher with MRU tab switching
* `"inOrder"`: Use the tab switcher, with in-order tab switching
* `false`, `"disabled"`: Don't use the tab switcher. Tabs will switch in-order.

This is following the discussion chronicled in #8025, as well as the follow-up investigation in that thread.

## References

* #7952 introduced MRU tab switching

## PR Checklist
* [x] Closes #8025 - there's also discussion of using a parameter in an action to override this setting, but that should get punted to a follow-up task
* [x] I work here
* [x] Tests added/passed - YOU BET THEY WERE
* [ ] Requires documentation to be updated

## Validation Steps Performed

I've been switching tabs all day and all night, with different settings values, and hot-reloading the setting.

I also _ran the test_ I added.
@ghost
Copy link

ghost commented Nov 11, 2020

🎉Windows Terminal v1.4.3141.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Nov 11, 2020

🎉Windows Terminal Preview v1.5.3142.0 has been released which incorporates this pull request.:tada:

Handy links:

@mselmanyildirim
Copy link

It seems, to achive the MRU behavior, you need to set the tabSwitcherMode entry in the settings.json file to mru from the default one, which is inOrder. This is also documented here, but this issue thread seems to be shown earlier in search results, so I wanted to make an update here.

Note: Valid as of version 1.11.2921.0

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Area-User Interface Issues pertaining to the user interface of the Console or Terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ctrl+Tab toggle between last two windows like Alt+Tab
4 participants