[vim/vim] Regression from patch 9.1.1479: %P in statusline no long behaves as documented (Issue #18669)

19 views
Skip to first unread message

zeertzjq

unread,
Oct 30, 2025, 10:10:10 AMOct 30
to vim/vim, Subscribed
zeertzjq created an issue (vim/vim#18669)

Steps to reproduce

  1. Run vim --clean
  2. Source the following file:
20new
set laststatus=2 statusline=%P
call setline(1, range(1, 40))
exe "normal! \<C-E>"
  1. The statusline shows "5%"

Expected behaviour

The statusline should show " 5%", according to documentation:

	P S   Percentage through file of displayed window.  This is like the
	      percentage described for 'ruler'.  Always 3 in length, unless
	      translated.

Version of Vim

9.1.1888

Environment

Operating system: Arch Linux
Terminal: kitty 0.43.1
Value of $TERM: xterm-kitty
Shell: fish 4.1.2

Logs and stack traces


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/18669@github.com>

zeertzjq

unread,
Oct 30, 2025, 10:17:14 AMOct 30
to vim/vim, Subscribed
zeertzjq left a comment (vim/vim#18669)

Perhaps it's better to just revert to the formatting before patch 9.1.1291:

diff --git a/src/buffer.c b/src/buffer.c
index 548df8051..ca2a2495d 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5427,10 +5427,9 @@ get_rel_pos(
 	    "%s", _("Top"));
 
     int perc = calc_percentage(above, above + below);
-    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, _("%s%d%%"),
+						 (perc < 10) ? " " : "", perc);
 }
 
 /*

But then the translation files may also need to be reverted?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/18669/3468247367@github.com>

Christ van Willegen

unread,
Oct 30, 2025, 10:29:01 AMOct 30
to vim...@googlegroups.com, reply+ACY5DGGLXQ34D5STRW...@reply.github.com, vim/vim, Subscribed
Hi,

Op do 30 okt 2025, 15:17 schreef zeertzjq <vim-dev...@256bit.org>:
zeertzjq left a comment (vim/vim#18669)

Perhaps it's better to just revert to the formatting before patch 9.1.1291

    return (int)vim_snprintf_safelen((char *)buf, buflen, _("%2s"), tmp);

Shouldn't that have been "% 3s"???

This needs fixing in the translation files as well, of course, or we can _() it to the correct value in English (but that's ugly).

Christ van Willegen

vim-dev ML

unread,
Oct 30, 2025, 10:29:43 AMOct 30
to vim/vim, vim-dev ML, Your activity
vim-ml left a comment (vim/vim#18669)
Hi,

Op do 30 okt 2025, 15:17 schreef zeertzjq ***@***.***>:

> *zeertzjq* left a comment (vim/vim#18669)
> <https://github.com/vim/vim/issues/18669#issuecomment-3468247367>

>
> Perhaps it's better to just revert to the formatting before patch 9.1.1291
>
return (int)vim_snprintf_safelen((char *)buf, buflen, _("%2s"), tmp);
>
>
Shouldn't that have been "% 3s"???

This needs fixing in the translation files as well, of course, or we can
_() it to the correct value in English (but that's ugly).

Christ van Willegen


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/18669/3468314852@github.com>

Christian Brabandt

unread,
Oct 30, 2025, 3:48:40 PMOct 30
to vim/vim, vim-dev ML, Comment
chrisbra left a comment (vim/vim#18669)

Yeah, I'd think the following should be fine (except for the required translation updates)?

diff --git a/src/buffer.c b/src/buffer.c
index 548df8051..44d7bdd09 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, _("%3.3s"), tmp);
 }

 /*

This should always be 3 characters wide percentage value, no?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/18669/3469801310@github.com>

zeertzjq

unread,
Oct 30, 2025, 6:47:39 PMOct 30
to vim/vim, vim-dev ML, Comment
zeertzjq left a comment (vim/vim#18669)

%3.3s doesn't look right. If %d%% has a multibyte translation but %3.3s, it may even truncate the percentage in the middle of the multibyte character.

However %3s does seem to work and doesn't require a translation update.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/18669/3470542249@github.com>

Christian Brabandt

unread,
Oct 30, 2025, 6:52:40 PMOct 30
to vim/vim, vim-dev ML, Comment
chrisbra left a comment (vim/vim#18669)

A numeric percentage?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/18669/3470573108@github.com>

zeertzjq

unread,
Oct 30, 2025, 7:00:44 PMOct 30
to vim/vim, vim-dev ML, Comment
zeertzjq left a comment (vim/vim#18669)

A numeric percentage?

I'm not sure what you are referring to.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/18669/3470624350@github.com>

Christian Brabandt

unread,
Oct 30, 2025, 7:11:54 PMOct 30
to vim/vim, vim-dev ML, Comment
chrisbra left a comment (vim/vim#18669)

Nevermind. Thanks for the pr


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/18669/3470664381@github.com>

Christian Brabandt

unread,
Oct 31, 2025, 5:12:18 AMOct 31
to vim/vim, vim-dev ML, Comment

Closed #18669 as completed via 73a0de4.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issue/18669/issue_event/20628646391@github.com>

Reply all
Reply to author
Forward
0 new messages