diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index d409858eb0..6b7ecd67dc 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1147,8 +1147,8 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op memmove(t + 1, t + n, (size_t)(out_p - (t + n))); out_p = out_p - n + 1; // Fill up space left over by half a double-wide char. - minwid = MIN(minwid, maxwid); - while (++group_len < minwid) { + int minwid_fixed = MIN(minwid, maxwid); + while (++group_len < minwid_fixed) { schar_get_adv(&out_p, fillchar); } // } @@ -1187,15 +1187,15 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op out_p += added_bytes; // } - // Adjust item start positions - for (int n = stl_groupitems[groupdepth] + 1; n < curitem; n++) { - stl_items[n].start += added_bytes; - } - // Prepend the fill characters for (; added_cells > 0; added_cells--) { schar_get_adv(&t, fillchar); } + + // Adjust item start positions + for (int n = stl_groupitems[groupdepth] + 1; n < curitem; n++) { + stl_items[n].start += added_bytes; + } } } continue; diff --git a/test/old/testdir/test_statusline.vim b/test/old/testdir/test_statusline.vim index 9685d42790..6d6b8818f7 100644 --- a/test/old/testdir/test_statusline.vim +++ b/test/old/testdir/test_statusline.vim @@ -124,10 +124,30 @@ func Test_statusline() call assert_match('^ Xstatusline\s*$', s:get_statusline()) set statusline=%.6(%f%) call assert_match('^3\s*$', s:get_statusline()) + for filler in ['-', '∙'] + exec 'set fillchars+=stl:'..filler + set statusline=%-5(x%),%-5.(x%),%-5.5(x%),%-5.10(x%); + call assert_match(substitute('^x____,x____,x____,x____;_*$', '_', filler, 'g'), s:get_statusline()) + set statusline=%5(x%),%5.(x%),%5.5(x%),%5.10(x%); + call assert_match(substitute('^____x,____x,____x,____x;_*$', '_', filler, 'g'), s:get_statusline()) + set statusline=%.5(12🙂345%),%4.5(12🙂345%),%5.5(12🙂345%),%50.5(12🙂345%); + call assert_match(substitute('^<345,<345,<345_,<345_;_*$', '_', filler, 'g'), s:get_statusline()) + endfor + if has('linux') + " This assumes MAXPATHL is 4096 bytes. + set stl=%{%repeat('x',4096-6)%}%10(X%) + set fillchars+=stl:- + call assert_match('^