Opt-in edge spillover: carry focus into the neighbouring tab / workspace - #10
Open
imagirom wants to merge 1 commit into
Open
Opt-in edge spillover: carry focus into the neighbouring tab / workspace#10imagirom wants to merge 1 commit into
imagirom wants to merge 1 commit into
Conversation
Ctrl+h/j/k/l stops dead at the edge of the pane layout. With HERDR_NAV_SPILL=1 the motion carries on into the neighbouring container instead, i3-style: left/right at the horizontal edge -> previous/next tab in this workspace up/down at the vertical edge -> previous/next workspace Both wrap, and focus then walks to the far side of the layout it lands in, so crossing rightwards puts you on the leftmost pane and the whole thing reads as one continuous motion. Off by default, same as HERDR_NAV_PASSTHROUGH_RE. `pane focus` already reports whether focus changed and which tab and workspace it happened in, so the edge is found by simply attempting the move: no separate probe, and one CLI call in the common case. The move targets the invoking pane, following e1ba690. The walk afterwards is the one place that stays on --current, deliberately: focusing the tab or workspace has already put the globally focused pane inside the container we just entered, which is what we want to walk from -- $HERDR_PANE_ID is back in the container we left. Tabs and workspaces are stepped in the order herdr lists them, which is their on-screen order. Indexing by .number would be wrong for tabs -- that is an id, not a position: it stays put when a tab is reordered, and closing a tab leaves a hole in the sequence. The editor side called `herdr pane focus` directly, so crossing out of a Vim split at a layout edge skipped all of this. It now goes through navigate.sh --no-detect when the file still sits in a plugin checkout, and keeps the direct call for when nvim.lua has been copied into after/plugin, as the README suggests. Without jq it degrades to plain focus, as before.
Owner
|
I will take a look over the weekend |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both the code and the PR description have largely been AI generated. I have read through both, and understood most of the code.
I have been using the feature for a couple of days without issues.
Closes #6.
Ctrl+h/j/k/lstops dead at the edge of the pane layout. WithHERDR_NAV_SPILL=1the motion carries on into the neighbouring container instead, i3-style:Ctrl+h/Ctrl+lat the left/right edge → previous/next tab in this workspaceCtrl+k/Ctrl+jat the top/bottom edge → previous/next workspaceBoth wrap, and focus then walks to the far side of the layout it lands in, so crossing rightwards puts you on the leftmost pane and the move reads as one continuous motion. Off by default, as agreed in #6.
Implementation notes
herdr pane focusalready reportsfocus.changedalong with the tab and workspace the move happened in, so the edge is found by simply attempting the move. One CLI call in the common case, and no dependency onpane edges.--current#8 and follows it: the move targets the invoking pane. The walk afterwards is the one place that stays on--current, deliberately — focusing the tab/workspace has already put the globally focused pane inside the container we just entered, which is what we want to walk from, while$HERDR_PANE_IDis back in the container we left.tab list/workspace listreturn them — their on-screen order. Indexing by.numberlooks right and isn't: for tabs it's an id, not a position, so it stays put when a tab is reordered and closing a tab leaves a hole (on 0.7.5, closing tab 2 leaves 1, 3, 4, 5). Workspace order isn't creation order either — a new local workspace can appear before existing remote ones.editor/vim.vimandeditor/nvim.luacalledherdr pane focusdirectly, so crossing out of a Vim split at a layout edge skipped all of this. They now callnavigate.sh --no-detectwhen the file still sits in a plugin checkout, and keep the direct call otherwise — socp editor/nvim.lua ~/.config/nvim/after/plugin/behaves exactly as it does today.--no-detectskips the Vim check, which is what stops the key being handed straight back to Vim.Compatibility
Behaviour is unchanged with
HERDR_NAV_SPILLunset. Withoutjqit degrades to plainpane focus, same as the existing Vim detection. A single tab / single workspace is a no-op, and without$HERDR_PANE_IDit falls back to global focus as #8 does.min_herdr_versionis unchanged — the only new CLI surface istab list/workspace list/tab focus/workspace focus.Testing
Manual, on herdr 0.7.5 (Linux), in a scratch workspace with a side-by-side tab, a stacked tab and a single-pane tab:
nvim.luacopied elsewhere (falls back to plainpane focus, still crosses panes)jqoff$PATH;HERDR_NAV_SPILLunset;$HERDR_PANE_IDunset; bad or missing direction argument exits non-zeroUnrelated, spotted while rebasing
#8 switched
editor/nvim.luato--pane "$HERDR_PANE_ID"but left the same--currentcall ineditor/vim.vim. I've left it alone to keep this PR to one thing — happy to fix it here or in a separate PR, whichever you prefer.Thanks @inadicis for raising it — happy to take you up on the logic review.