mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 08:48:16 +00:00
vim-patch:8.1.1835: cannot use printf() as a method
Problem: Cannot use printf() as a method.
Solution: Pass the base as the second argument to printf().
fd8ca21b3f
This commit is contained in:
@@ -6653,7 +6653,11 @@ printf({fmt}, {expr1} ...) *printf()*
|
|||||||
< May result in:
|
< May result in:
|
||||||
" 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
|
" 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
|
||||||
|
|
||||||
Often used items are:
|
When used as a |method| the base is passed as the second
|
||||||
|
argument: >
|
||||||
|
Compute()->printf("result: %d")
|
||||||
|
|
||||||
|
< Often used items are:
|
||||||
%s string
|
%s string
|
||||||
%6S string right-aligned in 6 display cells
|
%6S string right-aligned in 6 display cells
|
||||||
%6s string right-aligned in 6 bytes
|
%6s string right-aligned in 6 bytes
|
||||||
|
@@ -258,7 +258,7 @@ return {
|
|||||||
pathshorten={args=1},
|
pathshorten={args=1},
|
||||||
pow={args=2},
|
pow={args=2},
|
||||||
prevnonblank={args=1},
|
prevnonblank={args=1},
|
||||||
printf={args=varargs(1)},
|
printf={args=varargs(1), base=2},
|
||||||
prompt_getprompt={args=1},
|
prompt_getprompt={args=1},
|
||||||
prompt_setcallback={args={2, 2}},
|
prompt_setcallback={args={2, 2}},
|
||||||
prompt_setinterrupt={args={2, 2}},
|
prompt_setinterrupt={args={2, 2}},
|
||||||
|
@@ -72,13 +72,15 @@ func Test_dict_method()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_string_method()
|
func Test_string_method()
|
||||||
call assert_equal(['1', '2', '3'], '1 2 3'->split())
|
eval '1 2 3'->split()->assert_equal(['1', '2', '3'])
|
||||||
call assert_equal([1, 2, 3], '1 2 3'->split()->map({i, v -> str2nr(v)}))
|
eval '1 2 3'->split()->map({i, v -> str2nr(v)})->assert_equal([1, 2, 3])
|
||||||
call assert_equal([65, 66, 67], 'ABC'->str2list())
|
eval 'ABC'->str2list()->assert_equal([65, 66, 67])
|
||||||
call assert_equal(3, 'ABC'->strlen())
|
eval 'ABC'->strlen()->assert_equal(3)
|
||||||
call assert_equal('a^Mb^[c', "a\rb\ec"->strtrans())
|
eval "a\rb\ec"->strtrans()->assert_equal('a^Mb^[c')
|
||||||
call assert_equal(4, "aあb"->strwidth())
|
eval "aあb"->strwidth()->assert_equal(4)
|
||||||
call assert_equal('axc', 'abc'->substitute('b', 'x', ''))
|
eval 'abc'->substitute('b', 'x', '')->assert_equal('axc')
|
||||||
|
|
||||||
|
eval 'abc'->printf('the %s arg')->assert_equal('the abc arg')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_method_append()
|
func Test_method_append()
|
||||||
|
Reference in New Issue
Block a user