1
0
mirror of https://github.com/rivo/tview.git synced 2025-04-24 13:48:56 +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

16
flex.go
View File

@ -4,12 +4,16 @@ import (
"github.com/gdamore/tcell/v2" "github.com/gdamore/tcell/v2"
) )
// Configuration values. // Flex directions.
const ( const (
FlexRow = 0 // One item per row. // One item per row.
FlexColumn = 1 // One item per column. FlexRow = 0
FlexRowCSS = 1 // As defined in CSS, items distributed along a row. // One item per column.
FlexColumnCSS = 0 // As defined in CSS, items distributed within a 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. // flexItem holds layout options for one item.
@ -49,7 +53,7 @@ type Flex struct {
// background before any items are drawn, set it to a box with the desired // background before any items are drawn, set it to a box with the desired
// color: // color:
// //
// flex.Box = NewBox() // flex.Box = NewBox()
func NewFlex() *Flex { func NewFlex() *Flex {
f := &Flex{ f := &Flex{
direction: FlexColumn, direction: FlexColumn,

View File

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