1
0
mirror of https://github.com/rivo/tview.git synced 2025-04-26 13:49:06 +08:00

Checking line index before attempting purge. Fixes #891

This commit is contained in:
Oliver 2023-09-28 07:31:30 +02:00
parent 0ad06c2ea3
commit d7e1e3802f
2 changed files with 11 additions and 7 deletions

14
flex.go
View File

@ -4,12 +4,16 @@ import (
"github.com/gdamore/tcell/v2"
)
// Configuration values.
// Flex directions.
const (
FlexRow = 0 // One item per row.
FlexColumn = 1 // One item per column.
FlexRowCSS = 1 // As defined in CSS, items distributed along a row.
FlexColumnCSS = 0 // As defined in CSS, items distributed within a column.
// One item per row.
FlexRow = 0
// One item per column.
FlexColumn = 1
// As defined in CSS, items distributed along a row.
FlexRowCSS = 1
// As defined in CSS, items distributed within a column.
FlexColumnCSS = 0
)
// flexItem holds layout options for one item.

View File

@ -1259,7 +1259,7 @@ func (t *TextView) Draw(screen tcell.Screen) {
}
// Purge.
if purgeStart > 0 {
if purgeStart > 0 && purgeStart < len(t.lineIndex) {
newText := t.text.String()[t.lineIndex[purgeStart].offset:]
t.text.Reset()
t.text.WriteString(newText)