patch 9.1.1890: %P in 'statusline' doesn't behave as documented

Commit: 
https://github.com/vim/vim/commit/73a0de4a04b48ccaa0291f91fb69606c66d7cf8c
Author: zeertzjq <[email protected]>
Date:   Fri Oct 31 09:10:05 2025 +0000

    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 <[email protected]>
    Signed-off-by: zeertzjq <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/buffer.c b/src/buffer.c
index 548df8051..6e4990abd 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 9aa6aef66..4899bd0a0 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 4e0477dd9..5af88e611 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,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vElDy-00DfzU-Qo%40256bit.org.

Raspunde prin e-mail lui