diff --git a/src/highlighters.cc b/src/highlighters.cc index d2daa085..ee772469 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -1840,6 +1840,9 @@ struct ForwardHighlighterApplier cur_atom = cur_line->begin(); } + if (region_lines.empty()) + return; + region_display.compute_range(); highlighter.highlight(context, region_display, {begin, end}); diff --git a/test/regression/4926-crash-with-fold-and-ranges/cmd b/test/regression/4926-crash-with-fold-and-ranges/cmd new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/regression/4926-crash-with-fold-and-ranges/cmd @@ -0,0 +1 @@ + diff --git a/test/regression/4926-crash-with-fold-and-ranges/in b/test/regression/4926-crash-with-fold-and-ranges/in new file mode 100644 index 00000000..5c93113c --- /dev/null +++ b/test/regression/4926-crash-with-fold-and-ranges/in @@ -0,0 +1,4 @@ +{[foo]} +{[bar]} +{[baz]} +%( ) diff --git a/test/regression/4926-crash-with-fold-and-ranges/rc b/test/regression/4926-crash-with-fold-and-ranges/rc new file mode 100644 index 00000000..62d98e01 --- /dev/null +++ b/test/regression/4926-crash-with-fold-and-ranges/rc @@ -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