Prevent panics incase highlighting leads to different number of lines

This commit is contained in:
Kovid Goyal 2023-03-23 11:52:40 +05:30
parent 09c6a68804
commit 9c188096d0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -133,10 +133,14 @@ func lines_for_path(path string) ([]string, error) {
}
func highlighted_lines_for_path(path string) ([]string, error) {
if ans, found := highlighted_lines_cache.Get(path); found && ans != nil {
plain_lines, err := lines_for_path(path)
if err != nil {
return nil, err
}
if ans, found := highlighted_lines_cache.Get(path); found && len(ans) == len(plain_lines) {
return ans, nil
}
return lines_for_path(path)
return plain_lines, nil
}
type Collection struct {