mirror of
https://github.com/vim/vim.git
synced 2025-11-13 22:54:27 -05:00
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 <cvwillegen@gmail.com>
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
69dd5906fd
commit
73a0de4a04
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -729,6 +729,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1890,
|
||||
/**/
|
||||
1889,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user