mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 00:38:17 +00:00
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:
@@ -5477,7 +5477,7 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
|
|||||||
gettabwinvar({tabnr}, {winnr}, '&')
|
gettabwinvar({tabnr}, {winnr}, '&')
|
||||||
|
|
||||||
< Can also be used as a |method|: >
|
< Can also be used as a |method|: >
|
||||||
GetTabnr()->gettabvar(winnr, varname)
|
GetTabnr()->gettabwinvar(winnr, varname)
|
||||||
|
|
||||||
gettagstack([{winnr}]) *gettagstack()*
|
gettagstack([{winnr}]) *gettagstack()*
|
||||||
The result is a Dict, which is the tag stack of window {winnr}.
|
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.
|
See |tagstack| for more information about the tag stack.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetWinnr()->gettagstack()
|
||||||
|
|
||||||
getwininfo([{winid}]) *getwininfo()*
|
getwininfo([{winid}]) *getwininfo()*
|
||||||
Returns information about windows as a |List| with Dictionaries.
|
Returns information about windows as a |List| with Dictionaries.
|
||||||
|
|
||||||
@@ -5538,6 +5541,9 @@ getwininfo([{winid}]) *getwininfo()*
|
|||||||
winrow topmost screen line of the window;
|
winrow topmost screen line of the window;
|
||||||
"row" from |win_screenpos()|
|
"row" from |win_screenpos()|
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetWinnr()->getwininfo()
|
||||||
|
|
||||||
getwinpos([{timeout}]) *getwinpos()*
|
getwinpos([{timeout}]) *getwinpos()*
|
||||||
The result is a |List| with two numbers, the result of
|
The result is a |List| with two numbers, the result of
|
||||||
|getwinposx()| and |getwinposy()| combined:
|
|getwinposx()| and |getwinposy()| combined:
|
||||||
@@ -5557,6 +5563,9 @@ getwinpos([{timeout}]) *getwinpos()*
|
|||||||
endif
|
endif
|
||||||
" Do some work here
|
" Do some work here
|
||||||
endwhile
|
endwhile
|
||||||
|
<
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetTimeout()->getwinpos()
|
||||||
<
|
<
|
||||||
*getwinposx()*
|
*getwinposx()*
|
||||||
getwinposx() The result is a Number, which is the X coordinate in pixels of
|
getwinposx() The result is a Number, which is the X coordinate in pixels of
|
||||||
@@ -5575,6 +5584,9 @@ getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
|
|||||||
Examples: >
|
Examples: >
|
||||||
:let list_is_on = getwinvar(2, '&list')
|
:let list_is_on = getwinvar(2, '&list')
|
||||||
:echo "myvar = " . getwinvar(1, 'myvar')
|
:echo "myvar = " . getwinvar(1, 'myvar')
|
||||||
|
|
||||||
|
< Can also be used as a |method|: >
|
||||||
|
GetWinnr()->getwinvar(varname)
|
||||||
<
|
<
|
||||||
glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
|
glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
|
||||||
Expand the file wildcards in {expr}. See |wildcards| for the
|
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
|
See |expand()| for expanding special Vim variables. See
|
||||||
|system()| for getting the raw output of an external command.
|
|system()| for getting the raw output of an external command.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetExpr()->glob()
|
||||||
|
|
||||||
glob2regpat({string}) *glob2regpat()*
|
glob2regpat({string}) *glob2regpat()*
|
||||||
Convert a file pattern, as used by glob(), into a search
|
Convert a file pattern, as used by glob(), into a search
|
||||||
pattern. The result can be used to match with a string that
|
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
|
Note that the result depends on the system. On MS-Windows
|
||||||
a backslash usually means a path separator.
|
a backslash usually means a path separator.
|
||||||
|
|
||||||
*globpath()*
|
Can also be used as a |method|: >
|
||||||
|
GetExpr()->glob2regpat()
|
||||||
|
< *globpath()*
|
||||||
globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])
|
globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])
|
||||||
Perform glob() for String {expr} on all directories in {path}
|
Perform glob() for String {expr} on all directories in {path}
|
||||||
and concatenate the results. Example: >
|
and concatenate the results. Example: >
|
||||||
@@ -5660,6 +5677,10 @@ globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])
|
|||||||
< Upwards search and limiting the depth of "**" is not
|
< Upwards search and limiting the depth of "**" is not
|
||||||
supported, thus using 'path' will not always work properly.
|
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()*
|
||||||
has({feature}) Returns 1 if {feature} is supported, 0 otherwise. The
|
has({feature}) Returns 1 if {feature} is supported, 0 otherwise. The
|
||||||
{feature} argument is a feature name like "nvim-0.2.1" or
|
{feature} argument is a feature name like "nvim-0.2.1" or
|
||||||
|
@@ -172,15 +172,15 @@ return {
|
|||||||
gettabinfo={args={0, 1}, base=1},
|
gettabinfo={args={0, 1}, base=1},
|
||||||
gettabvar={args={2, 3}, base=1},
|
gettabvar={args={2, 3}, base=1},
|
||||||
gettabwinvar={args={3, 4}, base=1},
|
gettabwinvar={args={3, 4}, base=1},
|
||||||
gettagstack={args={0, 1}},
|
gettagstack={args={0, 1}, base=1},
|
||||||
getwininfo={args={0, 1}},
|
getwininfo={args={0, 1}, base=1},
|
||||||
getwinpos={args={0, 1}},
|
getwinpos={args={0, 1}, base=1},
|
||||||
getwinposx={},
|
getwinposx={},
|
||||||
getwinposy={},
|
getwinposy={},
|
||||||
getwinvar={args={2, 3}},
|
getwinvar={args={2, 3}, base=1},
|
||||||
glob={args={1, 4}},
|
glob={args={1, 4}, base=1},
|
||||||
glob2regpat={args=1},
|
glob2regpat={args=1, base=1},
|
||||||
globpath={args={2, 5}},
|
globpath={args={2, 5}, base=2},
|
||||||
has={args=1},
|
has={args=1},
|
||||||
has_key={args=2, base=1},
|
has_key={args=2, base=1},
|
||||||
haslocaldir={args={0,2}},
|
haslocaldir={args={0,2}},
|
||||||
|
@@ -77,7 +77,7 @@ function Test_getbufwintabinfo()
|
|||||||
|
|
||||||
call assert_equal('green', winlist[2].variables.signal)
|
call assert_equal('green', winlist[2].variables.signal)
|
||||||
call assert_equal(w4_id, winlist[3].winid)
|
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(2, winfo.tabnr)
|
||||||
call assert_equal([], getwininfo(3))
|
call assert_equal([], getwininfo(3))
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ function Test_glob()
|
|||||||
" Execute these commands in the sandbox, so that using the shell fails.
|
" Execute these commands in the sandbox, so that using the shell fails.
|
||||||
" Setting 'shell' to an invalid name causes a memory leak.
|
" 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("", glob('Xxx\$'))
|
sandbox call assert_equal("", 'Xxx\$'->glob())
|
||||||
w! Xxx\{
|
w! Xxx\{
|
||||||
" } to fix highlighting
|
" } to fix highlighting
|
||||||
w! Xxx\$
|
w! Xxx\$
|
||||||
@@ -30,5 +30,5 @@ function Test_globpath()
|
|||||||
sandbox call assert_equal(expand("sautest/autoload/globone.vim\nsautest/autoload/globtwo.vim"),
|
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')],
|
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
|
endfunction
|
||||||
|
@@ -12,8 +12,8 @@ func Test_var()
|
|||||||
let def_str = "Chance"
|
let def_str = "Chance"
|
||||||
call assert_equal('Dance', getwinvar(1, 'var_str'))
|
call assert_equal('Dance', getwinvar(1, 'var_str'))
|
||||||
call assert_equal('Dance', getwinvar(1, 'var_str', def_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'}, 1->getwinvar(''))
|
||||||
call assert_equal({'var_str': 'Dance'}, getwinvar(1, '', def_str))
|
call assert_equal({'var_str': 'Dance'}, 1->getwinvar('', def_str))
|
||||||
unlet w:var_str
|
unlet w:var_str
|
||||||
call assert_equal('Chance', getwinvar(1, 'var_str', def_str))
|
call assert_equal('Chance', getwinvar(1, 'var_str', def_str))
|
||||||
call assert_equal({}, getwinvar(1, ''))
|
call assert_equal({}, getwinvar(1, ''))
|
||||||
|
@@ -10,7 +10,7 @@ endfunc
|
|||||||
|
|
||||||
func Test_glob2regpat_valid()
|
func Test_glob2regpat_valid()
|
||||||
call assert_equal('^foo\.', glob2regpat('foo.*'))
|
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('\.vim$', glob2regpat('*.vim'))
|
||||||
call assert_equal('^[abc]$', glob2regpat('[abc]'))
|
call assert_equal('^[abc]$', glob2regpat('[abc]'))
|
||||||
call assert_equal('^foo bar$', glob2regpat('foo\ bar'))
|
call assert_equal('^foo bar$', glob2regpat('foo\ bar'))
|
||||||
|
@@ -316,7 +316,7 @@ func Test_getsettagstack()
|
|||||||
enew | only
|
enew | only
|
||||||
call settagstack(1, {'items' : []})
|
call settagstack(1, {'items' : []})
|
||||||
call assert_equal(0, gettagstack(1).length)
|
call assert_equal(0, gettagstack(1).length)
|
||||||
call assert_equal([], gettagstack(1).items)
|
call assert_equal([], 1->gettagstack().items)
|
||||||
" Error cases
|
" Error cases
|
||||||
call assert_equal({}, gettagstack(100))
|
call assert_equal({}, gettagstack(100))
|
||||||
call assert_equal(-1, settagstack(100, {'items' : []}))
|
call assert_equal(-1, settagstack(100, {'items' : []}))
|
||||||
|
Reference in New Issue
Block a user