From 742cf086196e7a18a43333d0b3c30a4edd56ed1f Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Thu, 18 Jan 2024 10:39:11 +0100 Subject: [PATCH] Handled a case where there could be highglights for non-existing regions. --- textview.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/textview.go b/textview.go index 6c914d8..682f139 100644 --- a/textview.go +++ b/textview.go @@ -1048,14 +1048,17 @@ func (t *TextView) Draw(screen tcell.Screen) { // Scroll to highlighted regions. if t.regionTags && t.scrollToHighlights { // Make sure we know all highlighted regions. + knownHighlights := make(map[string]struct{}) t.parseAhead(width, func(lineNumber int, line *textViewLine) bool { for regionID := range t.highlights { if _, ok := t.regions[regionID]; !ok { return false } + knownHighlights[regionID] = struct{}{} } return true }) + t.highlights = knownHighlights // What is the line range for all highlighted regions? var (