From 8f39595eaa57692aa7bcac19425bdea4ab4a3875 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Mon, 21 Jul 2025 16:04:32 -0400 Subject: [PATCH] fix(tui): cursor position in the textarea Hide the cursor when it's misaligned with the textarea. --- internal/tui/tui.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/tui/tui.go b/internal/tui/tui.go index 728437e6a9b46bf52c23b23a78f1cdeb4fa588c2..fa17910e550382c5b02cfe08426ed01f7ac5b268 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -3,6 +3,7 @@ package tui import ( "context" "fmt" + "strings" "github.com/charmbracelet/bubbles/v2/key" tea "github.com/charmbracelet/bubbletea/v2" @@ -453,6 +454,11 @@ func (a *appModel) View() tea.View { var cursor *tea.Cursor if v, ok := page.(util.Cursor); ok { cursor = v.Cursor() + // Hide the cursor if it's positioned outside the textarea + statusHeight := a.height - strings.Count(pageView, "\n") + 1 + if cursor != nil && cursor.Y+statusHeight+chat.EditorHeight-2 <= a.height { // 2 for the top and bottom app padding + cursor = nil + } } activeView := a.dialog.ActiveModel() if activeView != nil {