on main help sign in
fix(tui): cursor position in the textarea
8f39595Ayman Bagabas
internal/tui/tui.go+6
@@ -3,6 +3,7 @@ package tui
3import (
3import (
4 "context"
4 "context"
5 "fmt"
5 "fmt"
6+ "strings"
6
7
7 "github.com/charmbracelet/bubbles/v2/key"
8 "github.com/charmbracelet/bubbles/v2/key"
8 tea "github.com/charmbracelet/bubbletea/v2"
9 tea "github.com/charmbracelet/bubbletea/v2"
@@ -453,6 +454,11 @@ func (a *appModel) View() tea.View {
453 var cursor *tea.Cursor
454 var cursor *tea.Cursor
454 if v, ok := page.(util.Cursor); ok {
455 if v, ok := page.(util.Cursor); ok {
455 cursor = v.Cursor()
456 cursor = v.Cursor()
457+ // Hide the cursor if it's positioned outside the textarea
458+ statusHeight := a.height - strings.Count(pageView, "\n") + 1
459+ if cursor != nil && cursor.Y+statusHeight+chat.EditorHeight-2 <= a.height { // 2 for the top and bottom app padding
460+ cursor = nil
461+ }
456 }
462 }
457 activeView := a.dialog.ActiveModel()
463 activeView := a.dialog.ActiveModel()
458 if activeView != nil {
464 if activeView != nil {