-
Notifications
You must be signed in to change notification settings - Fork 918
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
Most recently used tab with Ctrl-Tab cycling #4671
Most recently used tab with Ctrl-Tab cycling #4671
Conversation
To do before ready for review:
|
a34b6a7
to
2b0f75c
Compare
03b4d1c
to
4cb05fc
Compare
Ufffff, that was harder than I first expected but I've now implemented everything I wanted :) First, I am a daily Brave user and what you're doing is awesome. This was my biggest frustration when moving from Firefox so I had a try. It's my first contribution to Brave and experience with the Chromium code base. It is certainly not yet perfect, I need some feedback. I have build and tested the feature on Linux (Ubuntu), Windows and Mac. The only missing piece is that Ctrl-Previous and Ctrl-Next are doing MRU switching as well. I originally wanted to do a simple switch to the previous and next tab even when the feature is activated. Unfortunately, Chromium treats Ctrl-Next and Ctrl-Previous the same way as Ctrl-Tab and Ctrl-Maj-Tab down to some quite lower level controllers. If we really need this feature we will have to do some more changes at the Chromium level. |
Thank you so much for getting deep in to this issue @guifel and persisting to get it working! I'll definitely review the UX impact and have a go at understanding if we can split the keyboard shortcuts as you mention. Special thanks for also putting the effort in to do the patching and overrides in a clean way. |
int current_mru_cycling_index = -1; | ||
|
||
// List of tab indexes sorted by most recently used | ||
std::vector<int> mru_cycle_list; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you checked base::MRUCache
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not aware of this class but I am not sure it is a good fit here. I am calculating from scratch the ordered set of tab indices at the beginning of each cycling session with std:sort
and the timestamp of last use.
base:MRUCache
keeps track of the ordering by calling the Put
function whenever the item is used.
To use MRUCache
I would need to call Put
each time a tab is accessed, not sure this is possible form TabStripModel
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. So it looks like that timestamp is being set in TabStripModel::ActivateTabAt
. What about overriding that method and calling base::MRUCache.Put
when the new tab is activated instead of doing your own MRU?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My problem with base::MRUCache
is that it's a map data-structure with key-value pairs. What I need is a simple MRU queue.
Also, I thought that relying on this already existing timestamp would be better than maintaining an additional index.
@guifel You are my hero. |
Thanks @Helldembez 🤣 but the PR is not yet merged. Brave team seems busy. |
@guifel do you think you can give this a rebase and squash the commits up a bit? I wouldn't squash into one commit, but try to group similar ones together (ex: where you fix review feedback). Let me know if you need help with that 😄 And huge thanks for submitting this- we'll definitely work with you to get it merged 😄 |
cd290d8
to
3c842c9
Compare
@bsclifton done. In the first commit I add the toggle button in the settings (which touches many files..) and in the second commit we have the core logic of the MRU tab switch. The 2 last commits are the requested changes by @yrliou and @iefremov. |
During the mru cycling, tab can be closed with shortcut. In that case, current cycling is ended and new cycling will be started.
Can't resolve now for chrome/browser circular dependency.
* Delete redundant IsKeyEvent() checking * Don't use MRU outside of TabStripModel.
28da6b5
to
9a91afa
Compare
@guifel, Finally merged! 🎉 |
Awesome to see this feature in the master! Thank you guys for the amazing job. |
@guifel thanks for your contribution and also your patience 😄 This is a great feature! This should be in Nightly in the next day or so 😄 |
woohoo at last... Here comes Brave With C-Tab |
FYI: I have submitted an issue to Chromium to consider merging/cherry-picking these commits into Chromium. https://bugs.chromium.org/p/chromium/issues/detail?id=1150395 |
@motevets awesome, thanks! That would be a great one to upstream |
Hi developer, there seems to be a bug in the MRU implementation. If you open just one new tab using |
Resolves brave/brave-browser#913
I implemented MRU cycling feature as requested in the issue. I added a new option under the section Tab "Cycle through the most recently used tabs with Ctrl-Tab" to activate the feature. Deactivated by default.
This is inspired by how MRU cycling is implemented at the ChromeOS level.
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
TBD
Reviewer Checklist:
After-merge Checklist:
changes has landed on.