File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -2137,14 +2137,15 @@ vim_vsnprintf_typval(
2137
2137
char * q = memchr (str_arg , '\0' ,
2138
2138
precision <= (size_t )0x7fffffffL ? precision
2139
2139
: (size_t )0x7fffffffL );
2140
+
2140
2141
str_arg_l = (q == NULL ) ? precision
2141
2142
: (size_t )(q - str_arg );
2142
2143
}
2143
2144
if (fmt_spec == 'S' )
2144
2145
{
2145
- if ( min_field_width != 0 )
2146
- min_field_width += STRLEN ( str_arg )
2147
- - mb_string2cells (( char_u * ) str_arg , -1 );
2146
+ size_t base_width = min_field_width ;
2147
+ size_t pad_cell = 0 ;
2148
+
2148
2149
if (precision )
2149
2150
{
2150
2151
char_u * p1 ;
@@ -2157,8 +2158,12 @@ vim_vsnprintf_typval(
2157
2158
if (i > precision )
2158
2159
break ;
2159
2160
}
2160
- str_arg_l = precision = p1 - (char_u * )str_arg ;
2161
+ pad_cell = min_field_width - precision ;
2162
+ base_width = str_arg_l = precision =
2163
+ p1 - (char_u * )str_arg ;
2161
2164
}
2165
+ if (min_field_width != 0 )
2166
+ min_field_width = base_width + pad_cell ;
2162
2167
}
2163
2168
break ;
2164
2169
Original file line number Diff line number Diff line change @@ -297,6 +297,11 @@ function Test_printf_misc()
297
297
call assert_equal (' 🐍' , printf (' %.2S' , ' 🐍🐍' ))
298
298
call assert_equal (' ' , printf (' %.1S' , ' 🐍🐍' ))
299
299
300
+ call assert_equal (' [ あいう]' , printf (' [%10.6S]' , ' あいうえお' ))
301
+ call assert_equal (' [ あいうえ]' , printf (' [%10.8S]' , ' あいうえお' ))
302
+ call assert_equal (' [あいうえお]' , printf (' [%10.10S]' , ' あいうえお' ))
303
+ call assert_equal (' [あいうえお]' , printf (' [%10.12S]' , ' あいうえお' ))
304
+
300
305
call assert_equal (' 1%' , printf (' %d%%' , 1 ))
301
306
endfunc
302
307
Original file line number Diff line number Diff line change @@ -757,6 +757,8 @@ static char *(features[]) =
757
757
758
758
static int included_patches [] =
759
759
{ /* Add new patch number below this line */
760
+ /**/
761
+ 3630 ,
760
762
/**/
761
763
3629 ,
762
764
/**/
You can’t perform that action at this time.
0 commit comments