]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1479: regression when displaying localized percentage position v9.1.1479
authorEmir SARI <emir_sari@icloud.com>
Wed, 25 Jun 2025 18:22:43 +0000 (20:22 +0200)
committerChristian Brabandt <cb@256bit.org>
Wed, 25 Jun 2025 18:22:43 +0000 (20:22 +0200)
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 <emir_sari@icloud.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/buffer.c
src/testdir/test_normal.vim
src/version.c

index fe19269a492c3d25d0af1ffd00f731abcda4ca8f..0bac265b7468b78249fa95f2684e84b7c8ad89c6 100644 (file)
@@ -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);
 }
 
 /*
index cbd90ec4e7e49a869e922e75c2819408753d4336..a8fe7b5f4c9fbfb2917cf3450c6deccd48515216 100644 (file)
@@ -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
index 6db18c6181a55670e82d0df6b291f3d07642dcb9..f36bcacdbbe14733f1f3c926a931f16600d06186 100644 (file)
@@ -709,6 +709,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1479,
 /**/
     1478,
 /**/