fix: disable mouse reporting so wheel sequences can't leak into search#18
Merged
Conversation
Scrolling the mouse wheel over results could insert escape sequences like "[<65;36;40M" into the search box. With mouse reporting enabled, a heavy frame (results + preview) lets the terminal emit SGR mouse reports faster than bubbletea reads them; batched reads leak the fragmented trailing reports through as typed runes. A content filter can't reliably catch them because they arrive split across reads. Disable mouse reporting entirely (drop tea.WithMouseCellMotion) so the terminal never sends mouse sequences - nothing to leak. Scrolling is keyboard-only now (arrows / Ctrl+P/N for the list, Ctrl+J/K or PgUp/PgDn for the preview), which already covered every action. Removes the now-dead MouseMsg handler, mouseInPreview state, its test, and the mouse-wheel mentions in help/README.
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.
Problem
Typing a query and scrolling the mouse wheel over the results inserted escape sequences like
[<65;36;40Mstraight into the search box. It only happened with results on screen, because the heavier frame (results + preview) lets the terminal emit SGR mouse-wheel reports faster than bubbletea reads them - batched reads parse the first as aMouseMsgand leak the fragmented trailing reports through as typed runes (e.g. a;36;40Mtail plus repeated[<65;36;40M).A content filter on the input was tried first but can't reliably catch these - they arrive split across reads, so partial fragments slip past any pattern match.
Fix
Disable mouse reporting entirely (drop
tea.WithMouseCellMotion). The terminal then never sends mouse sequences, so there's nothing to leak - a certain fix rather than a best-effort filter.Scrolling is keyboard-only now, which already covered everything:
↑/↓orCtrl+P/NCtrl+J/KorPgUp/PgDnRemoves the now-dead
MouseMsghandler,mouseInPreviewstate, its test, and the mouse-wheel mentions in--help/ README. Net -84 lines.Trade-off
Loses mouse-wheel scrolling. Given it was actively corrupting the search input and keyboard scrolling fully covers the use case, that's the right call. If wheel scroll is wanted back later, it'd need a bubbletea version/input-handling that doesn't fragment mouse reports under load.
Verify
go build,go test,go vetall pass; coverage 62.7%.