From ac98385e86991103fd971e79ee865e7d2712ecbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20R=C3=BChl?= Date: Fri, 5 Aug 2022 15:29:48 +0200 Subject: [PATCH] fix: fixed GetRegionText when colors are active When skipping color tags the currentTag is getting incremented and directly after that a index access with that happens. This always crashes on the last tag. --- textview.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/textview.go b/textview.go index 6ea4e73..1fd410e 100644 --- a/textview.go +++ b/textview.go @@ -621,10 +621,11 @@ func (t *TextView) GetRegionText(regionID string) string { for pos, ch := range str { // Skip any color tags. if currentTag < len(colorTagIndices) && pos >= colorTagIndices[currentTag][0] && pos < colorTagIndices[currentTag][1] { - if pos == colorTagIndices[currentTag][1]-1 { + tag := currentTag + if pos == colorTagIndices[tag][1]-1 { currentTag++ } - if colorTagIndices[currentTag][1]-colorTagIndices[currentTag][0] > 2 { + if colorTagIndices[tag][1]-colorTagIndices[tag][0] > 2 { continue } }