fix(ui): rework cursor can appear out of place on multi-line (#1948)

Ayman Bagabas created

Ensure we update the textarea after inserting a newline to keep the
cursor position accurate.

Change summary

internal/ui/model/ui.go | 3 +++
1 file changed, 3 insertions(+)

Detailed changes

internal/ui/model/ui.go 🔗

@@ -1479,6 +1479,9 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
 			case key.Matches(msg, m.keyMap.Editor.Newline):
 				m.textarea.InsertRune('\n')
 				m.closeCompletions()
+				ta, cmd := m.textarea.Update(msg)
+				m.textarea = ta
+				cmds = append(cmds, cmd)
 			default:
 				if handleGlobalKeys(msg) {
 					// Handle global keys first before passing to textarea.