mirror of
https://github.com/neovim/neovim.git
synced 2026-03-31 12:52:13 +00:00
vim-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: vim/vim#18669
closes: vim/vim#18671
73a0de4a04
Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user