Skip to content

Commit e7e2b9d

Browse files
authored
fix: text input width calculation (#144)
1 parent ebd0570 commit e7e2b9d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/ui/survey/prompt/string.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func NewStringModel(v recipe.Variable, styles style.Styles) StringModel {
3131
ti.Width = 30
3232

3333
if v.Default != "" {
34-
ti.Width = len(v.Default) - 3
34+
ti.Width = max(len(v.Default), ti.Width)
3535
ti.SetValue(v.Default)
3636
}
3737

@@ -71,7 +71,7 @@ func (m StringModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
7171

7272
case tea.WindowSizeMsg:
7373
m.width = msg.Width
74-
m.textInput.Width = msg.Width - 3
74+
m.textInput.Width = msg.Width - 3 // make sure that the '> ' prefix and the input fit on the line
7575
}
7676

7777
m.textInput, cmd = m.textInput.Update(msg)

0 commit comments

Comments
 (0)