Repository navigation
Keep the :ctx picker's cursor on screen when the context list is long - #11
Merged
Merged
Conversation
Signed-off-by: Tania Silva <[email protected]>
p3rsephone
force-pushed
the
ctx-picker-scroll
branch
from
October 16, 2026 19:13
78db347 to
5aee38e
Compare
Member
|
Nice catch, and thanks for the thorough write-up. I'd never hit this with my short kubeconfig, but the "enter switches to a context you can't see" part is nasty. Glad it's gone. Pulled the branch and poked at it a bit. The three tests do fail on main and pass here, and the row math lines up with what Tiny thing, not worth a round trip: the comment about the right-hand label ended up above the loop instead of next to the Merging now. The before/after screenshots made this an easy review. |
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.
With more contexts than fit in the main panel, the
:ctxpicker does not scroll. The arrow keys move the cursor, but the list always draws from the first context, so the highlighted row goes off the bottom of the screen and enter switches to a context you cannot see. The picker opens on the current context, so when that one sorts below the fold (k10s-demoafter a long kubeconfig) nothing is highlighted at all. The demo legend under the list is cut off too.contextBodyis given the number of rows the panel has, but it ignored it: it rendered every context andPaneldropped the lines that did not fit. It now draws only the rows that fit, centred on the cursor the way the theme picker does it, and keeps the header and the legend in view. Click zones need no change: bubblezone drops the zones of rows that are no longer drawn.Before
After
Tests
Tests in
internal/ui/ctxpicker_test.go, with 60 extra contexts on a 44-row screen:TestContextPickerKeepsTheCursorOnScreen: the highlighted row is on screen after moving down past the fold, at the end of the list, and back at the top.TestContextPickerOpensOnACurrentContextBelowTheFold: the picker opens onk10s-demoafter/demo, and that row is on screen.TestContextPickerKeepsTheLegendWithALongList: the demo legend is still drawn.All three fail on main. Checked with
gofmt,go vet ./...andgo test ./...on Go 1.27.2 and also 1.26.9. I also ran a build of this branch with a kubeconfig of 40 contexts in a 30-row terminal, and the cursor stays in view.