Cursor fix for empty text areas / input fields. Fixes #915

This commit is contained in:
Oliver 2023-11-15 19:32:40 +01:00
parent 05d01944a1
commit 7c9e464bac
1 changed files with 7 additions and 3 deletions

View File

@ -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.
}