patch 9.1.1479: regression when displaying localized percentage position
Commit:
https://github.com/vim/vim/commit/8fe9e55a7d92870f5bbaa592e1f3617e9cda33c6
Author: Emir SARI <[email protected]>
Date: Wed Jun 25 20:22:43 2025 +0200
patch 9.1.1479: regression when displaying localized percentage position
Problem: regression when displaying localized percentage position
(after v9.1.1291)
Solution: calculate percentage first (Emir SARI)
Cleanups made in ec032de broke the Turkish percent display, failing to
prepend it properly in cases between 0 and 10. In Turkish, the percent
sign is prepended to the number, so it was displaying it as `% 5`
(should have been `%5`), while displaying numbers bigger than 9 properly.
related: #17597
Signed-off-by: Emir SARI <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/buffer.c b/src/buffer.c
index fe19269a4..0bac265b7 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5411,9 +5411,11 @@ get_rel_pos(
return (int)vim_snprintf_safelen((char *)buf, buflen,
"%s", _("Top"));
+ int perc = calc_percentage(above, above + below);
+ char tmp[8];
// localized percentage value
- return (int)vim_snprintf_safelen((char *)buf, buflen,
- _("%2d%%"), calc_percentage(above, above + below));
+ vim_snprintf(tmp, sizeof(tmp), _("%d%%"), perc);
+ return (int)vim_snprintf_safelen((char *)buf, buflen, _("%2s"), tmp);
}
/*
diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim
index cbd90ec4e..a8fe7b5f4 100644
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -4377,4 +4377,30 @@ func Test_scroll_longline_winwidth()
bwipe!
endfunc
+func Test_pos_percentage_in_turkish_locale()
+ throw 'Skipped: FIXME: please remove throw when Turkish locale has been
updated!'
+ CheckRunVimInTerminal
+ defer execute(':lang C')
+
+ try
+ let dir = expand('$VIMRUNTIME/lang/tr/')
+ let target = expand('$VIMRUNTIME/lang/tr/LC_MESSAGES/')
+ let tr = '../po/tr.mo'
+ call mkdir(dir, 'R')
+ call mkdir(target, '')
+ call filecopy(tr, target .. 'vim.mo')
+ lang tr_TR.UTF-8
+ let buf = RunVimInTerminal('', {'rows': 5})
+ call term_sendkeys(buf, ":lang tr_TR.UTF-8\<cr>")
+ call term_sendkeys(buf, ":put =range(1,40)\<cr>")
+ call term_sendkeys(buf, ":5\<cr>")
+ call WaitForAssert({-> assert_match('%8$', term_getline(buf, 5))})
+
+ call StopVimInTerminal(buf)
+ catch /E197:/
+ " can't use Turkish locale
+ throw 'Skipped: Turkish locale not available'
+ endtry
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
diff --git a/src/version.c b/src/version.c
index 6db18c618..f36bcacdb 100644
--- a/src/version.c
+++ b/src/version.c
@@ -709,6 +709,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1479,
/**/
1478,
/**/
--
--
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/E1uUUso-002vqp-IH%40256bit.org.