workspace: Allow disabling tab cycles when using keyboard navigation#51253
Conversation
Add an optional `clamp` field to `ActivatePreviousItem` and
`ActivateNextItem` actions. When `clamp` is true, tab navigation
stops at the first/last tab instead of wrapping circularly.
Defaults to false, preserving existing behavior.
Usage in keymap.json:
"ctrl-h": ["pane::ActivatePreviousItem", { "clamp": true }]
"ctrl-l": ["pane::ActivateNextItem", { "clamp": true }]
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
clamp parameter to tab navigation actions
dinocosta
left a comment
There was a problem hiding this comment.
Hey @winzamark123 👋
I've checked out your changes and everything seems to be working, implementation also seems fine and appreciate you including tests for the introduced changes!
Will share with the team to see if there's an interest in introducing this. Will keep you posted 🙂
|
Thank you for the fast review @dinocosta ! Really appreciate what you guys have done / are doing with Zed. Looking forward to hearing back :3 |
|
Hey @dinocosta just checking in on this, did the team have a chance to follow up? Let me know if theres anything i can do to move this along! |
Rename the field for both `workspace::pane::ActivatePreviousItem` and `workspace::pane::ActivateNextItem` actions from `clamp` to `wrap_around` and default it to true, keeping the current default behavior.
dinocosta
left a comment
There was a problem hiding this comment.
Hey @winzamark123! 👋
Sorry for the slow response, I’ve been busy with other pull requests. I didn’t get much feedback from the team, but since this is a fairly small change with a limited surface area for errors, I think we’re fine to go ahead and introduce it.
I’ve renamed the clamp field to wrap_around, as I think it’s a bit clearer from a user-facing perspective. 🙂
Hi I've wanted this feature and looked through most open issues and pull request and couldn't find an implementation! Currently keymap of
pane::ActivatePreviousItemorpane::ActivateNextItemwill cycle through the tab when it reaches the end (either the start or the beginning). This PR allows the user to set whether they want to "clamp" it so that it doesn't cycle.Heres a video of before and after when the keyboard short cut has been set. Let me know if this needs more clarifying.
zed-wrap.mp4
Summary
wrap_aroundfield toActivatePreviousItemandActivateNextItempane actionswrap_around: false, tab navigation stops at the first/last tab instead of wrapping circularlytrue, fully preserving existing behaviorUsage
Taking the current default macOS keymap, one could update the current behavior with the following bindings:
{ "context": "Pane", "use_key_equivalents": true, "bindings": { "alt-cmd-left": ["pane::ActivatePreviousItem", { "wrap_around": false }], "cmd-{": ["pane::ActivatePreviousItem", { "wrap_around": false }], "alt-cmd-right": ["pane::ActivateNextItem", { "wrap_around": false }], "cmd-}": ["pane::ActivateNextItem", { "wrap_around": false }], }, }Test plan
test_activate_item_with_clampincrates/workspace/src/pane.rscovering:clamp: trueat last tab stays on last tabclamp: trueat first tab stays on first tabcargo test -p workspace,cargo test -p tab_switcher)clamp: truebindings stop at boundariesRelease Notes:
wrap_aroundoption to bothpane::ActivatePreviousItemandpane::ActivateNextItemactions to optionally disable wrapping when cycling past the first or last tab.