Skip to content

Fix TUI paste into TextArea and stale input state - #31

Merged
archlemon merged 1 commit into
mainfrom
fix/tui-input-state
Nov 28, 2026
Merged

archlemon merged 1 commit into
mainfrom
fix/tui-input-state

Conversation

@archlemon

Copy link
Copy Markdown
Member

Summary

Fixes #28, from the TUI audit.

  • Paste into a TextArea. Bracketed paste was dropped. bubbletea reports a paste as one KeyRunes message whose String() is "[text]", and the TextArea only accepted single-rune keys. Any rune key now inserts its runes. Alt chords still don't insert.
  • Stale editing state. r.inputs and r.areas were never pruned. State for generated per-row IDs grew forever, and an uncontrolled input hidden for one frame came back with its old typed text. Render now records which inputs and text areas it drew and drops the rest, so a returning control starts from its spec value like a newly mounted one.

Test plan

  • TestPasteIntoTextArea: a pasted string reaches OnChange, and alt+x inserts nothing. It fails on main ("paste produced ").
  • TestInputStateIsDroppedWhenTheControlLeaves: state is gone after a frame without the controls, and their old text doesn't come back. It fails on main ("1 inputs, 1 areas").
  • go test -race ./..., make e2e

- A bracketed paste into a focused TextArea was dropped: the key's
  String() is "[text]", which the single-rune branch ignored. Any
  rune key now inserts its runes; alt chords still do not.
- Input and text-area editing state was never evicted, so state for
  generated per-row IDs accumulated, and an uncontrolled input hidden
  for a frame came back with its old text. Render now drops the state
  of controls it did not draw.

Closes #28
@archlemon
archlemon merged commit aa70762 into main Nov 28, 2026
2 checks passed
@archlemon
archlemon deleted the fix/tui-input-state branch November 28, 2026 07:03
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.

TUI input state: paste into TextArea, stale state never evicted

1 participant