-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Clamp the focusTab
action to the number of available tabs
#10651
Conversation
Hmmmmmm. If we're going down this road... For consistency's sake, I need ctrl+alt+9 to focus the last tab. That's how firefox, chromium, chrome, edge, legacy edge, and a bunch of other tabbed interfaces do it. |
What's weird actually is how ^9 works in browsers. It is never tab 9. It is always "last tab"! |
Well, it is tab 9 if the last tab is tab 9. I should not have said "never." |
I mean, that's not too hard - setting it to { "command": { "action": "switchToTab", "index": 99999 }, "keys": "ctrl+alt+9" }, should work 😋 |
// GH#9369 - if the argument is out of range, then clamp to the number | ||
// of available tabs. Previously, we'd just silently do nothing if the | ||
// value was greater than the number of tabs. | ||
tabIndex = std::clamp(tabIndex, 0u, _tabs.Size() - 1); |
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.
tabIndex
can't be smaller than 0, so you can also use std::min
.
Hello @zadjii-msft! Because this pull request has the 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 (
|
…t#10651) ## Summary of the Pull Request When we perform a `focusTab` action, we currently do nothing if the parameter was greater than the number of tabs. This PR changes that behavior. Now, `focus-tab -t 999999` will always focus the last tab, instead of silently doing nothing. ## PR Checklist * [x] Closes microsoft#9369 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Validation Steps Performed * [x] ran tests * [x] validated commandline manually
🎉 Handy links: |
Summary of the Pull Request
When we perform a
focusTab
action, we currently do nothing if the parameter was greater than the number of tabs. This PR changes that behavior. Now,focus-tab -t 999999
will always focus the last tab, instead of silently doing nothing.PR Checklist
focus-tab
is greater than the number of tabs #9369Validation Steps Performed