vim-patch:8.1.1952: more functions can be used as a method

Problem:    More functions can be used as a method.
Solution:   Allow more functions to be used as a method.
5d69fdb7c4
This commit is contained in:
Sean Dewar 2021-08-31 22:41:44 +01:00
parent 3137c7d635
commit 8b7615c735
No known key found for this signature in database
GPG Key ID: 08CC2C83AD41B581
7 changed files with 38 additions and 17 deletions

View File

@ -5477,7 +5477,7 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
gettabwinvar({tabnr}, {winnr}, '&')
< Can also be used as a |method|: >
GetTabnr()->gettabvar(winnr, varname)
GetTabnr()->gettabwinvar(winnr, varname)
gettagstack([{winnr}]) *gettagstack()*
The result is a Dict, which is the tag stack of window {winnr}.
@ -5507,6 +5507,9 @@ gettagstack([{winnr}]) *gettagstack()*
See |tagstack| for more information about the tag stack.
Can also be used as a |method|: >
GetWinnr()->gettagstack()
getwininfo([{winid}]) *getwininfo()*
Returns information about windows as a |List| with Dictionaries.
@ -5538,6 +5541,9 @@ getwininfo([{winid}]) *getwininfo()*
winrow topmost screen line of the window;
"row" from |win_screenpos()|
Can also be used as a |method|: >
GetWinnr()->getwininfo()
getwinpos([{timeout}]) *getwinpos()*
The result is a |List| with two numbers, the result of
|getwinposx()| and |getwinposy()| combined:
@ -5557,6 +5563,9 @@ getwinpos([{timeout}]) *getwinpos()*
endif
" Do some work here
endwhile
<
Can also be used as a |method|: >
GetTimeout()->getwinpos()
<
*getwinposx()*
getwinposx() The result is a Number, which is the X coordinate in pixels of
@ -5575,6 +5584,9 @@ getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
Examples: >
:let list_is_on = getwinvar(2, '&list')
:echo "myvar = " . getwinvar(1, 'myvar')
< Can also be used as a |method|: >
GetWinnr()->getwinvar(varname)
<
glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
Expand the file wildcards in {expr}. See |wildcards| for the
@ -5612,6 +5624,9 @@ glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
See |expand()| for expanding special Vim variables. See
|system()| for getting the raw output of an external command.
Can also be used as a |method|: >
GetExpr()->glob()
glob2regpat({string}) *glob2regpat()*
Convert a file pattern, as used by glob(), into a search
pattern. The result can be used to match with a string that
@ -5624,7 +5639,9 @@ glob2regpat({string}) *glob2regpat()*
Note that the result depends on the system. On MS-Windows
a backslash usually means a path separator.
*globpath()*
Can also be used as a |method|: >
GetExpr()->glob2regpat()
< *globpath()*
globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])
Perform glob() for String {expr} on all directories in {path}
and concatenate the results. Example: >
@ -5660,6 +5677,10 @@ globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])
< Upwards search and limiting the depth of "**" is not
supported, thus using 'path' will not always work properly.
Can also be used as a |method|, the base is passed as the
second argument: >
GetExpr()->globpath(&rtp)
<
*has()*
has({feature}) Returns 1 if {feature} is supported, 0 otherwise. The
{feature} argument is a feature name like "nvim-0.2.1" or

View File

@ -172,15 +172,15 @@ return {
gettabinfo={args={0, 1}, base=1},
gettabvar={args={2, 3}, base=1},
gettabwinvar={args={3, 4}, base=1},
gettagstack={args={0, 1}},
getwininfo={args={0, 1}},
getwinpos={args={0, 1}},
gettagstack={args={0, 1}, base=1},
getwininfo={args={0, 1}, base=1},
getwinpos={args={0, 1}, base=1},
getwinposx={},
getwinposy={},
getwinvar={args={2, 3}},
glob={args={1, 4}},
glob2regpat={args=1},
globpath={args={2, 5}},
getwinvar={args={2, 3}, base=1},
glob={args={1, 4}, base=1},
glob2regpat={args=1, base=1},
globpath={args={2, 5}, base=2},
has={args=1},
has_key={args=2, base=1},
haslocaldir={args={0,2}},

View File

@ -77,7 +77,7 @@ function Test_getbufwintabinfo()
call assert_equal('green', winlist[2].variables.signal)
call assert_equal(w4_id, winlist[3].winid)
let winfo = getwininfo(w5_id)[0]
let winfo = w5_id->getwininfo()[0]
call assert_equal(2, winfo.tabnr)
call assert_equal([], getwininfo(3))

View File

@ -16,7 +16,7 @@ function Test_glob()
" Execute these commands in the sandbox, so that using the shell fails.
" Setting 'shell' to an invalid name causes a memory leak.
sandbox call assert_equal("", glob('Xxx\{'))
sandbox call assert_equal("", glob('Xxx\$'))
sandbox call assert_equal("", 'Xxx\$'->glob())
w! Xxx\{
" } to fix highlighting
w! Xxx\$
@ -28,7 +28,7 @@ endfunction
function Test_globpath()
sandbox call assert_equal(expand("sautest/autoload/globone.vim\nsautest/autoload/globtwo.vim"),
\ globpath('sautest/autoload', 'glob*.vim'))
\ globpath('sautest/autoload', 'glob*.vim'))
sandbox call assert_equal([expand('sautest/autoload/globone.vim'), expand('sautest/autoload/globtwo.vim')],
\ globpath('sautest/autoload', 'glob*.vim', 0, 1))
\ 'glob*.vim'->globpath('sautest/autoload', 0, 1))
endfunction

View File

@ -12,8 +12,8 @@ func Test_var()
let def_str = "Chance"
call assert_equal('Dance', getwinvar(1, 'var_str'))
call assert_equal('Dance', getwinvar(1, 'var_str', def_str))
call assert_equal({'var_str': 'Dance'}, getwinvar(1, ''))
call assert_equal({'var_str': 'Dance'}, getwinvar(1, '', def_str))
call assert_equal({'var_str': 'Dance'}, 1->getwinvar(''))
call assert_equal({'var_str': 'Dance'}, 1->getwinvar('', def_str))
unlet w:var_str
call assert_equal('Chance', getwinvar(1, 'var_str', def_str))
call assert_equal({}, getwinvar(1, ''))

View File

@ -10,7 +10,7 @@ endfunc
func Test_glob2regpat_valid()
call assert_equal('^foo\.', glob2regpat('foo.*'))
call assert_equal('^foo.$', glob2regpat('foo?'))
call assert_equal('^foo.$', 'foo?'->glob2regpat())
call assert_equal('\.vim$', glob2regpat('*.vim'))
call assert_equal('^[abc]$', glob2regpat('[abc]'))
call assert_equal('^foo bar$', glob2regpat('foo\ bar'))

View File

@ -316,7 +316,7 @@ func Test_getsettagstack()
enew | only
call settagstack(1, {'items' : []})
call assert_equal(0, gettagstack(1).length)
call assert_equal([], gettagstack(1).items)
call assert_equal([], 1->gettagstack().items)
" Error cases
call assert_equal({}, gettagstack(100))
call assert_equal(-1, settagstack(100, {'items' : []}))