From 83c9d1df1b11326327c69cb009235a2e02fb31ed Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 24 May 2019 01:10:59 -0400 Subject: vim-patch:8.0.1208: 'statusline' drops empty group with highlight change Problem: 'statusline' drops empty group with highlight change. Solution: Do not drop an empty group if it changes highlighting. (Marius Gedminas, closes vim/vim#2228) https://github.com/vim/vim/commit/6b89dbb55f84c485310c8c9e094dbafe3ecbace6 --- src/nvim/buffer.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/nvim/buffer.c') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index d944c654b0..88e19fd135 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3480,15 +3480,25 @@ 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 = 0; n < groupitems[groupdepth]; n++) { + if (items[n].type == Highlight) { + group_start_userhl = items[n].minwid; + } + } + 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 (!has_normal_items) { + if (n == curitem && group_start_userhl == group_end_userhl) { out_p = t; group_len = 0; } -- cgit From 4ed654d9e8873a4ed3666396a215cfd6287b4ef7 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 24 May 2019 02:04:56 -0400 Subject: vim-patch:8.0.1220: skipping empty statusline groups is not correct Problem: Skipping empty statusline groups is not correct. Solution: Also set group_end_userhl. (itchyny) https://github.com/vim/vim/commit/235dddf1f4afe3a40047dbf2aca1bd177b7be18b --- src/nvim/buffer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/buffer.c') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 88e19fd135..8a3d4ad418 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3485,9 +3485,10 @@ int build_stl_str_hl( int group_start_userhl = 0; int group_end_userhl = 0; int n; - for (n = 0; n < groupitems[groupdepth]; n++) { + for (n = groupitems[groupdepth] - 1; n >= 0; n--) { if (items[n].type == Highlight) { - group_start_userhl = items[n].minwid; + group_start_userhl = group_end_userhl = items[n].minwid; + break; } } for (n = groupitems[groupdepth] + 1; n < curitem; n++) { -- cgit