diff options
-rw-r--r-- | src/message.c | 14 | ||||
-rw-r--r-- | src/testdir/test_expr.vim | 3 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/message.c b/src/message.c index b40753415b..dd5f3f519b 100644 --- a/src/message.c +++ b/src/message.c @@ -4405,12 +4405,16 @@ vim_vsnprintf_typval( - mb_string2cells((char_u *)str_arg, -1); if (precision) { - char_u *p1 = (char_u *)str_arg; - size_t i; - - for (i = 0; i < precision && *p1; i++) - p1 += mb_ptr2len(p1); + char_u *p1; + size_t i = 0; + for (p1 = (char_u *)str_arg; *p1; + p1 += mb_ptr2len(p1)) + { + i += (size_t)mb_ptr2cells(p1); + if (i > precision) + break; + } str_arg_l = precision = p1 - (char_u *)str_arg; } } diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index 365a81344f..253cd49bc9 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -248,6 +248,9 @@ function Test_printf_misc() call assert_equal('abc ', printf('%-4s', 'abc')) call assert_equal('abc ', printf('%-4S', 'abc')) + call assert_equal('🐍', printf('%.2S', '🐍🐍')) + call assert_equal('', printf('%.1S', '🐍🐍')) + call assert_equal('1%', printf('%d%%', 1)) endfunc diff --git a/src/version.c b/src/version.c index fa4e956b20..98ddcca846 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2083, +/**/ 2082, /**/ 2081, |