aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index d944c654b0..8a3d4ad418 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -3480,15 +3480,26 @@ int build_stl_str_hl(
// Otherwise there would be no reason to do this step.
if (curitem > groupitems[groupdepth] + 1
&& items[groupitems[groupdepth]].minwid == 0) {
- bool has_normal_items = false;
- for (long n = groupitems[groupdepth] + 1; n < curitem; n++) {
- if (items[n].type == Normal || items[n].type == Highlight) {
- has_normal_items = true;
+ // remove group if all items are empty and highlight group
+ // doesn't change
+ int group_start_userhl = 0;
+ int group_end_userhl = 0;
+ int n;
+ for (n = groupitems[groupdepth] - 1; n >= 0; n--) {
+ if (items[n].type == Highlight) {
+ group_start_userhl = group_end_userhl = items[n].minwid;
break;
}
}
-
- if (!has_normal_items) {
+ for (n = groupitems[groupdepth] + 1; n < curitem; n++) {
+ if (items[n].type == Normal) {
+ break;
+ }
+ if (items[n].type == Highlight) {
+ group_end_userhl = items[n].minwid;
+ }
+ }
+ if (n == curitem && group_start_userhl == group_end_userhl) {
out_p = t;
group_len = 0;
}