Skip to content

Fix overlays navigation during search and after resizing - #31

Merged
kooler merged 8 commits into
kooler:mainfrom
gmist:fix-overlays-search
Oct 11, 2026
Merged

kooler merged 8 commits into
kooler:mainfrom
gmist:fix-overlays-search

Conversation

@gmist

@gmist gmist commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@kooler

kooler commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Great addition @gmist !

A few things on the new scroll code:

1. ClampScroll never lowers the offset when the window grows (internal/ui/overlay/overlay.go:141-155)

It only moves the offset to keep the cursor in view. It has no item count, so it can't cap the offset at len - height. If you shrink the terminal with the cursor past the first page and then make it bigger again, the offset stays where it was. The list then shows blank rows at the bottom while the top rows stay hidden. For example, take tablist with 30 rows and the cursor on row 25. At 100x40 the offset is 0. Resize to 100x12 and the offset becomes 21. Resize back to 100x40 and the offset is still 21, so rows 21-29 are drawn with 17 empty rows below them. This hits bookmarks, servers, tablist, themepicker and fuzzy. cmdexec.SetSize already caps it. Could ClampScroll take the item count and clamp offset to max(0, count-height)?

2. cmdexec.SetSize adds a third copy of the max-offset clamp (internal/ui/cmdexec/cmdexec.go:55-65)

The same three lines already exist in handleKey for down and pgdown. Quickview keeps this logic in maxOffset() + clampOffset(), and the other new SetSize methods just call m.clampOffset(). Pulling it into a clampOffset() method here would match that and remove the copies.

3. The ClampScroll doc comment says "Every scrollable list shares this" (internal/ui/overlay/overlay.go:139-140)

panel.go:458-468 and quickview.go:196-201 still have their own clampOffset. Panel also has an if m.height <= 0 { return } guard that ClampScroll doesn't have. Either move those two over or change the comment to say which lists use it.

@gmist

gmist commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author
  1. ClampScroll - added count param, now caps offset at max(0, count-height) so growing window can't leave blank row. Applied to bookmarks, servers, tablist, fuzzy, themepicker.
  2. cmdexec refactoring - extracted clampOffset(). quickview simplified too.
  3. panel/quickview now use shared overlay.ClampScroll . Doc comment is now accurate.

@kooler

kooler commented Oct 10, 2026

Copy link
Copy Markdown
Owner

thanks! one small issue remains: panel still keeps blank rows after a resize. panel.SetSize doesn’t call clampOffset(), so shrinking and then growing the terminal leaves the same blank rows in the main file panels. Scroll only fixes itself on the next key press that moves the cursor.

@gmist

gmist commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

I missed that point. Done.

@kooler

kooler commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Thanks, looks great now!

@kooler
kooler merged commit 53e3432 into kooler:main Oct 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter overlays get stuck on an empty list after Enter with no matches

2 participants