From 649f78e1fd8b5032c4316aed702c8a4ae24efa77 Mon Sep 17 00:00:00 2001 From: kena Date: Mon, 15 Aug 2022 16:25:20 +0200 Subject: [PATCH] fix(textarea): pre-allocation of value (#213) The maximum slice size of m.value is the max number of rows, which is the max height. --- textarea/textarea.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/textarea/textarea.go b/textarea/textarea.go index 5d6a115..b400dfe 100644 --- a/textarea/textarea.go +++ b/textarea/textarea.go @@ -193,7 +193,7 @@ func New() Model { Cursor: cur, KeyMap: DefaultKeyMap, - value: make([][]rune, minHeight, maxWidth), + value: make([][]rune, minHeight, maxHeight), focus: false, col: 0, row: 0, @@ -409,7 +409,7 @@ func (m *Model) Blur() { // Reset sets the input to its default state with no input. func (m *Model) Reset() { - m.value = make([][]rune, minHeight, maxWidth) + m.value = make([][]rune, minHeight, maxHeight) m.col = 0 m.row = 0 m.viewport.GotoTop()