Skip to content

Commit 2f6752d

Browse files
committed
Final fix
1 parent 8188db7 commit 2f6752d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

widget/textinput/textinput.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/charmbracelet/bubbles/textinput"
88
tea "github.com/charmbracelet/bubbletea"
9+
"github.com/charmbracelet/lipgloss"
910
)
1011

1112
type Widget struct {
@@ -75,7 +76,11 @@ func (w *Widget) Resize(size orvyn.Size) {
7576
// Bubbles' View() always renders the cursor as one extra column past
7677
// the value, so reserve 1 column on top of the prompt width. Without
7778
// the constant -1 the box grows by one column once a value is typed.
78-
w.Model.Width -= 1 + len(w.Model.Prompt)
79+
// Measure the prompt in display columns (matching Bubbles' own
80+
// lipgloss.Width), not bytes: a multi-byte rune such as 'Ǥ' is 2 bytes
81+
// but 1 column, and len() would over-subtract and shrink the box.
82+
promptWidth := lipgloss.Width(w.Model.PromptStyle.Render(w.Model.Prompt))
83+
w.Model.Width -= 1 + promptWidth
7984
}
8085

8186
// For the Bubbles textinput to process the update

0 commit comments

Comments
 (0)