diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-04-29 19:46:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-29 19:46:47 +0800 |
commit | 65fdd019b3f74a653b511282745004994d649857 (patch) | |
tree | e1d0f02351c9738667c118d2c04b917c98cc0292 /src/nvim/buffer.c | |
parent | 9f2fd8994841f344cfc269d30a4542fcddaecc5f (diff) | |
download | rneovim-65fdd019b3f74a653b511282745004994d649857.tar.gz rneovim-65fdd019b3f74a653b511282745004994d649857.tar.bz2 rneovim-65fdd019b3f74a653b511282745004994d649857.zip |
vim-patch:9.0.1497: the ruler percentage can't be localized (#23389)
Problem: The ruler percentage can't be localized.
Solution: Use a string that can be translated. (Emir Sari, closes vim/vim#12311)
https://github.com/vim/vim/commit/971cd2b8bc3e3a7faa886162cd7568938c627882
Co-authored-by: Emir SARI <emir_sari@icloud.com>
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r-- | src/nvim/buffer.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 14a07489a0..8d730733d0 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3470,8 +3470,8 @@ void free_titles(void) #endif -/// Get relative cursor position in window into "buf[buflen]", in the form 99%, -/// using "Top", "Bot" or "All" when appropriate. +/// Get relative cursor position in window into "buf[buflen]", in the localized +/// percentage form like %99, 99%; using "Top", "Bot" or "All" when appropriate. void get_rel_pos(win_T *wp, char *buf, int buflen) { // Need at least 3 chars for writing. @@ -3495,9 +3495,20 @@ void get_rel_pos(win_T *wp, char *buf, int buflen) } else if (above <= 0) { xstrlcpy(buf, _("Top"), (size_t)buflen); } else { - vim_snprintf(buf, (size_t)buflen, "%2d%%", above > 1000000L - ? (int)(above / ((above + below) / 100L)) - : (int)(above * 100L / (above + below))); + int perc = (above > 1000000L + ? (int)(above / ((above + below) / 100L)) + : (int)(above * 100L / (above + below))); + + char *p = buf; + size_t l = (size_t)buflen; + if (perc < 10) { + // prepend one space + buf[0] = ' '; + p++; + l--; + } + // localized percentage value + vim_snprintf(p, l, _("%d%%"), perc); } } |