2
0
mirror of https://github.com/rivo/tview.git synced 2024-11-15 06:12:46 +00:00

Handled a case where there could be highglights for non-existing regions.

This commit is contained in:
Oliver 2024-01-18 10:39:11 +01:00
parent d3aebefdd2
commit 742cf08619

View File

@ -1048,14 +1048,17 @@ func (t *TextView) Draw(screen tcell.Screen) {
// Scroll to highlighted regions. // Scroll to highlighted regions.
if t.regionTags && t.scrollToHighlights { if t.regionTags && t.scrollToHighlights {
// Make sure we know all highlighted regions. // Make sure we know all highlighted regions.
knownHighlights := make(map[string]struct{})
t.parseAhead(width, func(lineNumber int, line *textViewLine) bool { t.parseAhead(width, func(lineNumber int, line *textViewLine) bool {
for regionID := range t.highlights { for regionID := range t.highlights {
if _, ok := t.regions[regionID]; !ok { if _, ok := t.regions[regionID]; !ok {
return false return false
} }
knownHighlights[regionID] = struct{}{}
} }
return true return true
}) })
t.highlights = knownHighlights
// What is the line range for all highlighted regions? // What is the line range for all highlighted regions?
var ( var (