diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 07f6ccc81b..50d9277c11 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3482,7 +3482,7 @@ int get_rel_pos(win_T *wp, char *buf, int buflen) char tmp[8]; // localized percentage value vim_snprintf(tmp, sizeof(tmp), _("%d%%"), perc); - return (int)vim_snprintf_safelen(buf, (size_t)buflen, _("%2s"), tmp); + return (int)vim_snprintf_safelen(buf, (size_t)buflen, _("%3s"), tmp); } /// Append (2 of 8) to "buf[]", if editing more than one file. diff --git a/test/old/testdir/test_statusline.vim b/test/old/testdir/test_statusline.vim index 6886700e83..a24c1f9964 100644 --- a/test/old/testdir/test_statusline.vim +++ b/test/old/testdir/test_statusline.vim @@ -166,9 +166,16 @@ func Test_statusline() call assert_match('^0,Top\s*$', s:get_statusline()) norm G call assert_match('^100,Bot\s*$', s:get_statusline()) - 9000 - " Don't check the exact percentage as it depends on the window size - call assert_match('^90,\(Top\|Bot\|\d\+%\)\s*$', s:get_statusline()) + " The exact percentage depends on the window height, so create a window with + " known height. + 9000 | botright 10split | setlocal scrolloff=0 | normal! zb + call assert_match('^90,89%\s*$', s:get_statusline()) + normal! zt + call assert_match('^90,90%\s*$', s:get_statusline()) + " %P should result in a string with 3 in length when not translated. + normal! 500zb + call assert_match('^5, 4%\s*$', s:get_statusline()) + close " %q: "[Quickfix List]", "[Location List]" or empty. set statusline=%q