[GH-ISSUE #751] Textview can't get GetRegionText with colored content and panics #550

Closed
opened 2026-03-04 01:05:56 +03:00 by kerem · 1 comment
Owner

Originally created by @sruehl on GitHub (Aug 3, 2022).
Original GitHub issue: https://github.com/rivo/tview/issues/751

There is a guard to only check if the current tag currentTag has a index in colorTagIndices:
github.com/rivo/tview@711ef394f9/textview.go (L623)
when it hits the end tag it increments the currentTag
github.com/rivo/tview@711ef394f9/textview.go (L625)
and then produces a panic in the next line because the new tag is not bound checked against colorTagIndices
github.com/rivo/tview@711ef394f9/textview.go (L627)

Originally created by @sruehl on GitHub (Aug 3, 2022). Original GitHub issue: https://github.com/rivo/tview/issues/751 There is a guard to only check if the current tag `currentTag` has a index in `colorTagIndices`: https://github.com/rivo/tview/blob/711ef394f9b31ad219f5f7bbc85bddfb766af6ab/textview.go#L623 when it hits the end tag it increments the `currentTag` https://github.com/rivo/tview/blob/711ef394f9b31ad219f5f7bbc85bddfb766af6ab/textview.go#L625 and then produces a panic in the next line because the new tag is not bound checked against `colorTagIndices` https://github.com/rivo/tview/blob/711ef394f9b31ad219f5f7bbc85bddfb766af6ab/textview.go#L627
kerem closed this issue 2026-03-04 01:05:57 +03:00
Author
Owner

@sruehl commented on GitHub (Aug 3, 2022):

so from my understanding that would be solved by changing 627 to if currentTag < len(colorTagIndices) && colorTagIndices[currentTag][1]-colorTagIndices[currentTag][0] > 2 {

<!-- gh-comment-id:1203896875 --> @sruehl commented on GitHub (Aug 3, 2022): so from my understanding that would be solved by changing 627 to `if currentTag < len(colorTagIndices) && colorTagIndices[currentTag][1]-colorTagIndices[currentTag][0] > 2 { `
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#550
No description provided.