diff --git a/internal/ui/rich/parser/markup/markup.go b/internal/ui/rich/parser/markup/markup.go index 5d95c94..872ae86 100644 --- a/internal/ui/rich/parser/markup/markup.go +++ b/internal/ui/rich/parser/markup/markup.go @@ -262,6 +262,11 @@ func RenderCmplxWithConfig(content text.Rich, cfg RenderConfig) RenderOutput { var lastIndex = 0 for _, index := range appended.Finalize(len(content.Content)) { + // Prevent faulty backend with erroneous insertions. + if index > len(content.Content) { + index = len(content.Content) + } + // Write the content. buf.WriteString(html.EscapeString(content.Content[lastIndex:index])) // Write the tags.