on main help sign in
fix(tui): editor: make sure we move the cursor to the end of input
77e46cfAyman Bagabas
internal/tui/components/chat/editor/editor.go+4−3
@@ -187,6 +187,7 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
187 }
187 }
188 case openEditorMsg:
188 case openEditorMsg:
189 m.textarea.SetValue(msg.Text)
189 m.textarea.SetValue(msg.Text)
190+ m.textarea.MoveToEnd()
190 case tea.KeyPressMsg:
191 case tea.KeyPressMsg:
191 switch {
192 switch {
192 // Completions
193 // Completions
@@ -389,11 +390,11 @@ func NewEditorCmp(app *app.App) util.Model {
389 t := styles.CurrentTheme()
390 t := styles.CurrentTheme()
390 ta := textarea.New()
391 ta := textarea.New()
391 ta.SetStyles(t.S().TextArea)
392 ta.SetStyles(t.S().TextArea)
392− ta.SetPromptFunc(4, func(lineIndex int, focused bool) string {
393+ ta.SetPromptFunc(4, func(info textarea.PromptInfo) string {
393− if lineIndex == 0 {
394+ if info.LineNumber == 0 {
394 return " > "
395 return " > "
395 }
396 }
396− if focused {
397+ if info.Focused {
397 return t.S().Base.Foreground(t.GreenDark).Render("::: ")
398 return t.S().Base.Foreground(t.GreenDark).Render("::: ")
398 } else {
399 } else {
399 return t.S().Muted.Render("::: ")
400 return t.S().Muted.Render("::: ")