diff --git a/textview.go b/textview.go index 7855366..fa0356c 100644 --- a/textview.go +++ b/textview.go @@ -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.