fix(tui): editor: position completions correctly and account for padding

Ayman Bagabas created

Change summary

internal/tui/components/chat/editor/editor.go      | 5 +++--
internal/tui/components/completions/completions.go | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)

Detailed changes

internal/tui/components/chat/editor/editor.go 🔗

@@ -361,8 +361,9 @@ func (m *editorCmp) startCompletions() tea.Msg {
 		})
 	}
 
-	x := m.textarea.Cursor().X + m.x + 1
-	y := m.textarea.Cursor().Y + m.y + 1
+	cur := m.textarea.Cursor()
+	x := cur.X + m.x // adjust for padding
+	y := cur.Y + m.y + 1
 	return completions.OpenCompletionsMsg{
 		Completions: completionItems,
 		X:           x,

internal/tui/components/completions/completions.go 🔗

@@ -43,7 +43,7 @@ type Completions interface {
 type completionsCmp struct {
 	width  int
 	height int  // Height of the completions component`
-	x      int  // X position for the completions popup\
+	x      int  // X position for the completions popup
 	y      int  // Y position for the completions popup
 	open   bool // Indicates if the completions are open
 	keyMap KeyMap