From: zeertzjq Date: Fri, 31 Oct 2025 09:10:05 +0000 (+0000) Subject: patch 9.1.1890: %P in 'statusline' doesn't behave as documented X-Git-Tag: v9.1.1890^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=73a0de4a04b48cca;p=thirdparty%2Fvim.git patch 9.1.1890: %P in 'statusline' doesn't behave as documented Problem: %P in 'statusline' doesn't behave as documented (after 9.1.1479). Solution: Make the percentage 3-chars wide when not translated. (zeertzjq) fixes: #18669 closes: #18671 Co-authored-by: Christ van Willegen Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt --- diff --git a/src/buffer.c b/src/buffer.c index 548df80516..6e4990abdf 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -5430,7 +5430,7 @@ get_rel_pos( char tmp[8]; // localized percentage value vim_snprintf(tmp, sizeof(tmp), _("%d%%"), perc); - return (int)vim_snprintf_safelen((char *)buf, buflen, _("%2s"), tmp); + return (int)vim_snprintf_safelen((char *)buf, buflen, _("%3s"), tmp); } /* diff --git a/src/testdir/test_statusline.vim b/src/testdir/test_statusline.vim index 9aa6aef664..4899bd0a05 100644 --- a/src/testdir/test_statusline.vim +++ b/src/testdir/test_statusline.vim @@ -168,9 +168,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 diff --git a/src/version.c b/src/version.c index 4e0477dd9f..5af88e6115 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1890, /**/ 1889, /**/