fix(textinput): resolve placeholder truncation on initial render#816
fix(textinput): resolve placeholder truncation on initial render#816sebastianhuus wants to merge 1 commit intocharmbracelet:masterfrom
Conversation
The placeholderView function incorrectly sized the rune slice using m.Width+1, which created a slice of length 1 when Width was 0 during initial render. This truncated multi-character placeholders to just their first character. Fixed by ensuring the slice is always large enough to hold the entire placeholder text and updated the early return condition to check the actual placeholder length. Fixes charmbracelet#779 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
@sebastianhuus @meowgorithm can we get this landed? |
|
@kwlzn currently ill but I can take a look during the week and update my fork. While looking at other similar PRs and their Discord, I got the impression that changes like this weren't prioritized because they're working on shipping v2 of bubbles. I haven't followed the space since then so I'm not sure if that's still a concern. From what I understood V2 contains extra terminal-specific features and support for a lot more terminals. |
|
@kwlzn I see #768 (merged October 2025) includes a refactor that also addresses this bug. It was shipped to v2.0.0-rc.1 (November 2025), but Gum uses Bubbles v0.21 (April 2025). @meowgorithm If you could ship this fix before v2, then I suggest to release a intermediary patch v0.21.1 or v0.22 is released for Bubbles and Gum's dependency is updated respectively. I tested Master branch of Bubbles as dependency for gum and the bug is fixed for me. Screen.Recording.2026-01-30.at.22.13.43.mov |








Summary
Problem
The
placeholderViewfunction intextinput.gowas creating a rune slice with sizem.Width+1. Whenm.Widthis 0 during initial render, this created a slice of length 1, truncating multi-character placeholders to just their first character.Solution
m.Width+1tomax(len(m.Placeholder), m.Width+1)to ensure it can always hold the full placeholderlen(m.Placeholder)instead oflen(p)Test plan
All tests show full placeholder text immediately on render, no more truncation.
Fixes #779