Fix highlighters being applied to empty display buffers

In some cases such as with folding we can end-up with regions
not having any atoms to highlight which can trigger a crash as
we assume display buffers not to be empty

Fixes #4926
This commit is contained in:
Maxime Coste 2023-06-19 12:55:55 +10:00
parent 7027cccf82
commit e58592f00a
4 changed files with 14 additions and 0 deletions

View File

@ -1840,6 +1840,9 @@ struct ForwardHighlighterApplier
cur_atom = cur_line->begin(); cur_atom = cur_line->begin();
} }
if (region_lines.empty())
return;
region_display.compute_range(); region_display.compute_range();
highlighter.highlight(context, region_display, {begin, end}); highlighter.highlight(context, region_display, {begin, end});

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,4 @@
{[foo]}
{[bar]}
{[baz]}
%( )

View File

@ -0,0 +1,6 @@
declare-option range-specs fold %val{timestamp} 1.1,3.8|folded
add-highlighter buffer/regions regions
add-highlighter buffer/regions/curly region \{ \} regions
add-highlighter buffer/regions/curly/brace region \[ \] fill green
add-highlighter buffer/fold replace-ranges fold