tview icon indicating copy to clipboard operation
tview copied to clipboard

Textview can't get GetRegionText with colored content and panics

Open sruehl opened this issue 3 years ago • 1 comments

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

sruehl avatar Aug 03 '22 12:08 sruehl

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

sruehl avatar Aug 03 '22 12:08 sruehl