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.
This commit is contained in:
kena 2022-08-15 16:25:20 +02:00 committed by GitHub
parent e72e4a190b
commit 649f78e1fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()