TextView.GetText() and .GetRegionText() didn't filter out empty colour tags. Fixes #453

This commit is contained in:
Oliver 2020-07-12 13:34:19 +02:00 committed by Trevor Slocum
parent bf31b0001a
commit 81c828bfe0
1 changed files with 9 additions and 2 deletions

View File

@ -307,7 +307,12 @@ func (t *TextView) GetText(stripTags bool) string {
text = regionPattern.ReplaceAllString(text, "")
}
if t.dynamicColors {
text = colorPattern.ReplaceAllString(text, "")
text = colorPattern.ReplaceAllStringFunc(text, func(match string) string {
if len(match) > 2 {
return ""
}
return match
})
}
if t.regions || t.dynamicColors {
text = escapePattern.ReplaceAllString(text, `[$1$2]`)
@ -634,7 +639,9 @@ func (t *TextView) GetRegionText(regionID string) string {
if pos == colorTagIndices[currentTag][1]-1 {
currentTag++
}
continue
if colorTagIndices[currentTag][1]-colorTagIndices[currentTag][0] > 2 {
continue
}
}
// Skip any regions.