Skip to content

Commit 8188db7

Browse files
committed
New fix
1 parent 727307e commit 8188db7

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

demo/screen/inputwidgetdemo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func NewInputWidgetDemo() *InputWidgetDemo {
2424
s := new(InputWidgetDemo)
2525

2626
s.tiDemo = textinput.New()
27-
s.tiDemo.Prompt = ">"
27+
s.tiDemo.Prompt = "> "
2828
s.tiDemo.Placeholder = "Amazing placeholder"
2929
//s.tiDemo.Placeholder = "Placeholder"
3030

widget/textinput/textinput.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ func (w *Widget) Resize(size orvyn.Size) {
7272
w.Model.Width = contentSize.Width
7373

7474
if len(w.Model.Value()) > 0 || len(w.Model.Placeholder) == 0 {
75-
w.Model.Width--
76-
w.Model.Width -= len(w.Model.Prompt)
75+
// Bubbles' View() always renders the cursor as one extra column past
76+
// the value, so reserve 1 column on top of the prompt width. Without
77+
// the constant -1 the box grows by one column once a value is typed.
78+
w.Model.Width -= 1 + len(w.Model.Prompt)
7779
}
7880

7981
// For the Bubbles textinput to process the update

0 commit comments

Comments
 (0)