From 7c9e464bac026809d043dda41727113178f278e7 Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Wed, 15 Nov 2023 19:32:40 +0100 Subject: [PATCH] Cursor fix for empty text areas / input fields. Fixes #915 --- textarea.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/textarea.go b/textarea.go index 1cc23b6..33b3e43 100644 --- a/textarea.go +++ b/textarea.go @@ -1218,10 +1218,14 @@ func (t *TextArea) Draw(screen tcell.Screen) { } }() - // Placeholder. - if t.length == 0 && len(t.placeholder) > 0 { - t.drawPlaceholder(screen, x, y, width, height) + // No text / placeholder. + if t.length == 0 { t.lastHeight, t.lastWidth = height, width + t.cursor.row, t.cursor.column, t.cursor.actualColumn, t.cursor.pos = 0, 0, 0, [3]int{1, 0, -1} + t.rowOffset, t.columnOffset = 0, 0 + if len(t.placeholder) > 0 { + t.drawPlaceholder(screen, x, y, width, height) + } return // We're done already. }