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.
This commit is contained in:
Sebastian Rühl 2022-08-05 15:29:48 +02:00
parent 711ef394f9
commit ac98385e86
1 changed files with 3 additions and 2 deletions

View File

@ -621,10 +621,11 @@ func (t *TextView) GetRegionText(regionID string) string {
for pos, ch := range str { for pos, ch := range str {
// Skip any color tags. // Skip any color tags.
if currentTag < len(colorTagIndices) && pos >= colorTagIndices[currentTag][0] && pos < colorTagIndices[currentTag][1] { 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++ currentTag++
} }
if colorTagIndices[currentTag][1]-colorTagIndices[currentTag][0] > 2 { if colorTagIndices[tag][1]-colorTagIndices[tag][0] > 2 {
continue continue
} }
} }