fix(tui): paste support and stray-t placeholder fix - #299
Merged
Merged
Conversation
Two bugs in the search-as-you-type bar:
1. Paste (CMD+V / bracketed paste):
Model.Update never handled tea.PasteMsg (the event terminals emit
on CMD+V when bracketed-paste mode is active), so the message fell
through to return m, nil and was silently dropped.
Fix: add an explicit case tea.PasteMsg that forwards to
m.input.Update and re-filters the list.
2. Stray 't' when search expression is empty:
bubbles/v2 placeholderView() renders the first rune of the
placeholder ('t' from "type to filter...") as a virtualCursor
character. In terminals that fall back to printing the cursor char
as text this appeared as a literal 't' prefix on the input line.
Fix: clear the textinput Placeholder and instead append a dim
"type to filter..." hint *after* m.input.View() only when the
query is empty, rendering it as plain styled text.
Both fixes apply to Model (main switcher TUI) and listModel (RunList).
7 new unit tests cover both bugs and key edge-cases.
Signed-off-by: Michael Sprauer <Michael.Sprauer@sap.com>
Signed-off-by: Michael Sprauer <Michael.Sprauer@sap.com>
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
Two bugs in the search-as-you-type bar:
1. CMD+V paste did nothing
tea.PasteMsg(the bracketed-paste event terminals emit on CMD+V / paste) was never handled inModel.Update. It fell through toreturn m, niland was silently dropped.2. Stray
twhen search expression is emptybubbles/v2placeholderView()renders the first rune of the placeholder (tfrom"type to filter...") as avirtualCursorcharacter. In terminals that fall back to printing the cursor char as text, this appeared as a literaltprefix on the input line.Fix
Paste — added
case tea.PasteMsginModel.Updatethat forwards tom.input.Updateand re-filters the list. Same fix forlistModel.Stray t — cleared the textinput
Placeholderand instead appended a dim"type to filter..."hint afterm.input.View()only when the query is empty, rendering it as plain styled text (no cursor-char tricks).Tests
7 new unit tests in
pkg/tui/model_test.gocovering:TestNoStrayT_EmptyQuery— input line must not start withtTestHintTextAppended_EmptyQuery— hint appears when query is emptyTestHintTextGone_NonEmptyQuery— hint disappears once user typesTestPasteMsg_UpdatesQuery— paste sets the queryTestPasteMsg_TriggersRefilter— paste re-filters the listTestPasteMsg_EmptyContent— empty paste is a no-opTestPasteMsg_AppendsToExistingQuery— paste appends to existing typed text