fix(textinput): resolve placeholder truncation on initial render#816
fix(textinput): resolve placeholder truncation on initial render#816sebastianhuus wants to merge 3 commits intocharmbracelet:masterfrom
Conversation
|
@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).
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.movEdit 25 April 2026: I see I suggested Bubbles v0.21.1 but I have to admit I didn't dig that deep into it – it has been released in February 3 |
|
So is this being addressed? Gum is unusable. |
|
@marksalpeter Which version of Gum and/or Bubbles are you using? It seems to be working on v2 for me. |
|
@andreynering please ack that the latest release of gum is broken on osx. |
| ) | ||
|
|
||
| p := make([]rune, m.Width+1) | ||
| p := make([]rune, max(len(m.Placeholder), m.Width+1)) |
There was a problem hiding this comment.
len here would give incorrect placeholder cell/grapheme width
There was a problem hiding this comment.
Ok thanks for the review Ayman. I'll update the branch and take a look
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 <noreply@anthropic.com>
8722eb6 to
9edc16c
Compare
Fix calculation of the placeholder rune slice length by converting the placeholder string to a rune slice before taking its length. Ensures multi-byte characters are measured correctly and prevents improper sizing of the placeholder buffer when the placeholder contains non-ASCII characters.
|
Right. While updating my fork git reminded me that the bug is already fixed in Bubbles but Gum is still using the old Bubbles version. See my post above
That's a gum release/dependency issue, not something this PR should solve. |
|
@aymanbagabas Any info if a new Gum release is planned with updated dependencies? |
|
For any interested users, maybe it is more appropriate to keep the discussion in the Gum repo, since it has not been updated since 2025. Then this PR can be closed without merge while we ask for a new gum release with the fix applied? Particularly this issue is where I initially started when I had this issue. |
|
@sebastianhuus I see an abandoned branch in gum that attempted to version bump everything to v2. Maybe it was too ambitious. If this patches the prior version, a minor version bump will be much easier to merge than a major one. |
Interesting, can be worth a shot. I think its better to salvage the new fix from v2 and patch that into a PR that can become a minor patch – I found it a bit more pragmatic. |
|
Found a nicer fix actually – than making some PR patch. Tracking the fix in the other PR, the fix was released to Bubbles 0.21.1 3rd February. I forked Gum again, checked out the 0.17.0 version and bumped Bubbles 0.21.0 -> 0.21.1. Screen.Recording.2026-04-25.at.20.34.40.movI hopped on the Charm discord and asked if they'd be kind enough to just bump the dependency in Gum and release it as a patch – no PR needed. I guess its in the works but doesn't hurt to ask again :) |









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