0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.1.1925: more functions can be used as methods

Problem:    More functions can be used as methods.
Solution:   Make various functions usable as a method.
This commit is contained in:
Bram Moolenaar
2019-08-24 22:58:31 +02:00
parent a8eee21e75
commit 4c313b13fb
15 changed files with 110 additions and 46 deletions

View File

@@ -2450,7 +2450,7 @@ getbufline({expr}, {lnum} [, {end}])
List lines {lnum} to {end} of buffer {expr} List lines {lnum} to {end} of buffer {expr}
getbufvar({expr}, {varname} [, {def}]) getbufvar({expr}, {varname} [, {def}])
any variable {varname} in buffer {expr} any variable {varname} in buffer {expr}
getchangelist({expr}) List list of change list items getchangelist([{expr}]) List list of change list items
getchar([expr]) Number get one character from the user getchar([expr]) Number get one character from the user
getcharmod() Number modifiers for the last typed character getcharmod() Number modifiers for the last typed character
getcharsearch() Dict last character search getcharsearch() Dict last character search
@@ -4816,6 +4816,9 @@ getbufline({expr}, {lnum} [, {end}])
Example: > Example: >
:let lines = getbufline(bufnr("myfile"), 1, "$") :let lines = getbufline(bufnr("myfile"), 1, "$")
< Can also be used as a |method|: >
GetBufnr()->getbufline(lnum)
getbufvar({expr}, {varname} [, {def}]) *getbufvar()* getbufvar({expr}, {varname} [, {def}]) *getbufvar()*
The result is the value of option or local buffer variable The result is the value of option or local buffer variable
{varname} in buffer {expr}. Note that the name without "b:" {varname} in buffer {expr}. Note that the name without "b:"
@@ -4835,8 +4838,11 @@ getbufvar({expr}, {varname} [, {def}]) *getbufvar()*
Examples: > Examples: >
:let bufmodified = getbufvar(1, "&mod") :let bufmodified = getbufvar(1, "&mod")
:echo "todo myvar = " . getbufvar("todo", "myvar") :echo "todo myvar = " . getbufvar("todo", "myvar")
< Can also be used as a |method|: >
GetBufnr()->getbufvar(varname)
< <
getchangelist({expr}) *getchangelist()* getchangelist([{expr}]) *getchangelist()*
Returns the |changelist| for the buffer {expr}. For the use Returns the |changelist| for the buffer {expr}. For the use
of {expr}, see |bufname()| above. If buffer {expr} doesn't of {expr}, see |bufname()| above. If buffer {expr} doesn't
exist, an empty list is returned. exist, an empty list is returned.
@@ -4852,6 +4858,9 @@ getchangelist({expr}) *getchangelist()*
position refers to the position in the list. For other position refers to the position in the list. For other
buffers, it is set to the length of the list. buffers, it is set to the length of the list.
Can also be used as a |method|: >
GetBufnr()->getchangelist()
getchar([expr]) *getchar()* getchar([expr]) *getchar()*
Get a single character from the user or input stream. Get a single character from the user or input stream.
If [expr] is omitted, wait until a character is available. If [expr] is omitted, wait until a character is available.
@@ -5051,6 +5060,9 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
If there are no matches, an empty list is returned. An If there are no matches, an empty list is returned. An
invalid value for {type} produces an error. invalid value for {type} produces an error.
Can also be used as a |method|: >
GetPattern()->getcompletion('color')
<
*getcurpos()* *getcurpos()*
getcurpos() Get the position of the cursor. This is like getpos('.'), but getcurpos() Get the position of the cursor. This is like getpos('.'), but
includes an extra item in the list: includes an extra item in the list:
@@ -5097,6 +5109,9 @@ getcwd([{winnr} [, {tabnr}]])
:echo getcwd(-1, 3) :echo getcwd(-1, 3)
" Get the working directory of current tabpage " Get the working directory of current tabpage
:echo getcwd(-1, 0) :echo getcwd(-1, 0)
< Can also be used as a |method|: >
GetWinnr()->getcwd()
< <
getenv({name}) *getenv()* getenv({name}) *getenv()*
Return the value of environment variable {name}. Return the value of environment variable {name}.
@@ -5105,6 +5120,9 @@ getenv({name}) *getenv()*
some systems interpret the empty value as the variable being some systems interpret the empty value as the variable being
deleted. See also |expr-env|. deleted. See also |expr-env|.
Can also be used as a |method|: >
GetVarname()->getenv()
getfontname([{name}]) *getfontname()* getfontname([{name}]) *getfontname()*
Without an argument returns the name of the normal font being Without an argument returns the name of the normal font being
used. Like what is used for the Normal highlight group used. Like what is used for the Normal highlight group
@@ -5134,6 +5152,9 @@ getfperm({fname}) *getfperm()*
< This will hopefully (from a security point of view) display < This will hopefully (from a security point of view) display
the string "rw-r--r--" or even "rw-------". the string "rw-r--r--" or even "rw-------".
Can also be used as a |method|: >
GetFilename()->getfperm()
<
For setting permissions use |setfperm()|. For setting permissions use |setfperm()|.
getfsize({fname}) *getfsize()* getfsize({fname}) *getfsize()*
@@ -5144,6 +5165,9 @@ getfsize({fname}) *getfsize()*
If the size of {fname} is too big to fit in a Number then -2 If the size of {fname} is too big to fit in a Number then -2
is returned. is returned.
Can also be used as a |method|: >
GetFilename()->getfsize()
getftime({fname}) *getftime()* getftime({fname}) *getftime()*
The result is a Number, which is the last modification time of The result is a Number, which is the last modification time of
the given file {fname}. The value is measured as seconds the given file {fname}. The value is measured as seconds
@@ -5151,6 +5175,9 @@ getftime({fname}) *getftime()*
|localtime()| and |strftime()|. |localtime()| and |strftime()|.
If the file {fname} can't be found -1 is returned. If the file {fname} can't be found -1 is returned.
Can also be used as a |method|: >
GetFilename()->getftime()
getftype({fname}) *getftype()* getftype({fname}) *getftype()*
The result is a String, which is a description of the kind of The result is a String, which is a description of the kind of
file of the given file {fname}. file of the given file {fname}.
@@ -5172,6 +5199,9 @@ getftype({fname}) *getftype()*
"file" are returned. On MS-Windows a symbolic link to a "file" are returned. On MS-Windows a symbolic link to a
directory returns "dir" instead of "link". directory returns "dir" instead of "link".
Can also be used as a |method|: >
GetFilename()->getftype()
getjumplist([{winnr} [, {tabnr}]]) *getjumplist()* getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
Returns the |jumplist| for the specified window. Returns the |jumplist| for the specified window.
@@ -5191,7 +5221,10 @@ getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
filename filename if available filename filename if available
lnum line number lnum line number
*getline()* Can also be used as a |method|: >
GetWinnr()->getjumplist()
< *getline()*
getline({lnum} [, {end}]) getline({lnum} [, {end}])
Without {end} the result is a String, which is line {lnum} Without {end} the result is a String, which is line {lnum}
from the current buffer. Example: > from the current buffer. Example: >
@@ -5214,6 +5247,9 @@ getline({lnum} [, {end}])
:let end = search("^$") - 1 :let end = search("^$") - 1
:let lines = getline(start, end) :let lines = getline(start, end)
< Can also be used as a |method|: >
ComputeLnum()->getline()
< To get lines from another buffer see |getbufline()| < To get lines from another buffer see |getbufline()|
getloclist({nr} [, {what}]) *getloclist()* getloclist({nr} [, {what}]) *getloclist()*
@@ -5289,6 +5325,9 @@ getpos({expr}) Get the position for {expr}. For possible values of {expr}
call setpos("'a", save_a_mark) call setpos("'a", save_a_mark)
< Also see |getcurpos()| and |setpos()|. < Also see |getcurpos()| and |setpos()|.
Can also be used as a |method|: >
GetMark()->getpos()
getqflist([{what}]) *getqflist()* getqflist([{what}]) *getqflist()*
Returns a list with all the current quickfix errors. Each Returns a list with all the current quickfix errors. Each
@@ -5405,6 +5444,9 @@ getreg([{regname} [, 1 [, {list}]]]) *getreg()*
If {regname} is not specified, |v:register| is used. If {regname} is not specified, |v:register| is used.
Can also be used as a |method|: >
GetRegname()->getreg()
getregtype([{regname}]) *getregtype()* getregtype([{regname}]) *getregtype()*
The result is a String, which is type of register {regname}. The result is a String, which is type of register {regname}.
@@ -5416,6 +5458,9 @@ getregtype([{regname}]) *getregtype()*
<CTRL-V> is one character with value 0x16. <CTRL-V> is one character with value 0x16.
If {regname} is not specified, |v:register| is used. If {regname} is not specified, |v:register| is used.
Can also be used as a |method|: >
GetRegname()->getregtype()
gettabinfo([{arg}]) *gettabinfo()* gettabinfo([{arg}]) *gettabinfo()*
If {arg} is not specified, then information about all the tab If {arg} is not specified, then information about all the tab
pages is returned as a List. Each List item is a Dictionary. pages is returned as a List. Each List item is a Dictionary.
@@ -5429,6 +5474,9 @@ gettabinfo([{arg}]) *gettabinfo()*
tabpage-local variables tabpage-local variables
windows List of |window-ID|s in the tab page. windows List of |window-ID|s in the tab page.
Can also be used as a |method|: >
GetTabnr()->gettabinfo()
gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()* gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
Get the value of a tab-local variable {varname} in tab page Get the value of a tab-local variable {varname} in tab page
{tabnr}. |t:var| {tabnr}. |t:var|
@@ -5439,6 +5487,9 @@ gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
When the tab or variable doesn't exist {def} or an empty When the tab or variable doesn't exist {def} or an empty
string is returned, there is no error message. string is returned, there is no error message.
Can also be used as a |method|: >
GetTabnr()->gettabvar(varname)
gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()* gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
Get the value of window-local variable {varname} in window Get the value of window-local variable {varname} in window
{winnr} in tab page {tabnr}. {winnr} in tab page {tabnr}.
@@ -5465,6 +5516,9 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
To obtain all window-local variables use: > To obtain all window-local variables use: >
gettabwinvar({tabnr}, {winnr}, '&') gettabwinvar({tabnr}, {winnr}, '&')
< Can also be used as a |method|: >
GetTabnr()->gettabvar(winnr, varname)
gettagstack([{nr}]) *gettagstack()* gettagstack([{nr}]) *gettagstack()*
The result is a Dict, which is the tag stack of window {nr}. The result is a Dict, which is the tag stack of window {nr}.
{nr} can be the window number or the |window-ID|. {nr} can be the window number or the |window-ID|.
@@ -8006,6 +8060,9 @@ setfperm({fname}, {mode}) *setfperm()* *chmod*
Returns non-zero for success, zero for failure. Returns non-zero for success, zero for failure.
Can also be used as a |method|: >
GetFilename()->setfperm(mode)
<
To read permissions see |getfperm()|. To read permissions see |getfperm()|.

View File

@@ -561,9 +561,9 @@ static funcentry_T global_functions[] =
{"garbagecollect", 0, 1, 0, f_garbagecollect}, {"garbagecollect", 0, 1, 0, f_garbagecollect},
{"get", 2, 3, FEARG_1, f_get}, {"get", 2, 3, FEARG_1, f_get},
{"getbufinfo", 0, 1, 0, f_getbufinfo}, {"getbufinfo", 0, 1, 0, f_getbufinfo},
{"getbufline", 2, 3, 0, f_getbufline}, {"getbufline", 2, 3, FEARG_1, f_getbufline},
{"getbufvar", 2, 3, 0, f_getbufvar}, {"getbufvar", 2, 3, FEARG_1, f_getbufvar},
{"getchangelist", 1, 1, 0, f_getchangelist}, {"getchangelist", 0, 1, FEARG_1, f_getchangelist},
{"getchar", 0, 1, 0, f_getchar}, {"getchar", 0, 1, 0, f_getchar},
{"getcharmod", 0, 0, 0, f_getcharmod}, {"getcharmod", 0, 0, 0, f_getcharmod},
{"getcharsearch", 0, 0, 0, f_getcharsearch}, {"getcharsearch", 0, 0, 0, f_getcharsearch},
@@ -571,27 +571,27 @@ static funcentry_T global_functions[] =
{"getcmdpos", 0, 0, 0, f_getcmdpos}, {"getcmdpos", 0, 0, 0, f_getcmdpos},
{"getcmdtype", 0, 0, 0, f_getcmdtype}, {"getcmdtype", 0, 0, 0, f_getcmdtype},
{"getcmdwintype", 0, 0, 0, f_getcmdwintype}, {"getcmdwintype", 0, 0, 0, f_getcmdwintype},
{"getcompletion", 2, 3, 0, f_getcompletion}, {"getcompletion", 2, 3, FEARG_1, f_getcompletion},
{"getcurpos", 0, 0, 0, f_getcurpos}, {"getcurpos", 0, 0, 0, f_getcurpos},
{"getcwd", 0, 2, 0, f_getcwd}, {"getcwd", 0, 2, FEARG_1, f_getcwd},
{"getenv", 1, 1, 0, f_getenv}, {"getenv", 1, 1, FEARG_1, f_getenv},
{"getfontname", 0, 1, 0, f_getfontname}, {"getfontname", 0, 1, 0, f_getfontname},
{"getfperm", 1, 1, 0, f_getfperm}, {"getfperm", 1, 1, FEARG_1, f_getfperm},
{"getfsize", 1, 1, 0, f_getfsize}, {"getfsize", 1, 1, FEARG_1, f_getfsize},
{"getftime", 1, 1, 0, f_getftime}, {"getftime", 1, 1, FEARG_1, f_getftime},
{"getftype", 1, 1, 0, f_getftype}, {"getftype", 1, 1, FEARG_1, f_getftype},
{"getjumplist", 0, 2, 0, f_getjumplist}, {"getjumplist", 0, 2, FEARG_1, f_getjumplist},
{"getline", 1, 2, 0, f_getline}, {"getline", 1, 2, FEARG_1, f_getline},
{"getloclist", 1, 2, 0, f_getloclist}, {"getloclist", 1, 2, 0, f_getloclist},
{"getmatches", 0, 1, 0, f_getmatches}, {"getmatches", 0, 1, 0, f_getmatches},
{"getpid", 0, 0, 0, f_getpid}, {"getpid", 0, 0, 0, f_getpid},
{"getpos", 1, 1, 0, f_getpos}, {"getpos", 1, 1, FEARG_1, f_getpos},
{"getqflist", 0, 1, 0, f_getqflist}, {"getqflist", 0, 1, 0, f_getqflist},
{"getreg", 0, 3, 0, f_getreg}, {"getreg", 0, 3, FEARG_1, f_getreg},
{"getregtype", 0, 1, 0, f_getregtype}, {"getregtype", 0, 1, FEARG_1, f_getregtype},
{"gettabinfo", 0, 1, 0, f_gettabinfo}, {"gettabinfo", 0, 1, FEARG_1, f_gettabinfo},
{"gettabvar", 2, 3, 0, f_gettabvar}, {"gettabvar", 2, 3, FEARG_1, f_gettabvar},
{"gettabwinvar", 3, 4, 0, f_gettabwinvar}, {"gettabwinvar", 3, 4, FEARG_1, f_gettabwinvar},
{"gettagstack", 0, 1, 0, f_gettagstack}, {"gettagstack", 0, 1, 0, f_gettagstack},
{"getwininfo", 0, 1, 0, f_getwininfo}, {"getwininfo", 0, 1, 0, f_getwininfo},
{"getwinpos", 0, 1, 0, f_getwinpos}, {"getwinpos", 0, 1, 0, f_getwinpos},
@@ -793,7 +793,7 @@ static funcentry_T global_functions[] =
{"setcharsearch", 1, 1, 0, f_setcharsearch}, {"setcharsearch", 1, 1, 0, f_setcharsearch},
{"setcmdpos", 1, 1, 0, f_setcmdpos}, {"setcmdpos", 1, 1, 0, f_setcmdpos},
{"setenv", 2, 2, 0, f_setenv}, {"setenv", 2, 2, 0, f_setenv},
{"setfperm", 2, 2, 0, f_setfperm}, {"setfperm", 2, 2, FEARG_1, f_setfperm},
{"setline", 2, 2, 0, f_setline}, {"setline", 2, 2, 0, f_setline},
{"setloclist", 2, 4, 0, f_setloclist}, {"setloclist", 2, 4, 0, f_setloclist},
{"setmatches", 1, 2, 0, f_setmatches}, {"setmatches", 1, 2, 0, f_setmatches},
@@ -4477,10 +4477,15 @@ f_getchangelist(typval_T *argvars, typval_T *rettv)
return; return;
#ifdef FEAT_JUMPLIST #ifdef FEAT_JUMPLIST
(void)tv_get_number(&argvars[0]); /* issue errmsg if type error */ if (argvars[0].v_type == VAR_UNKNOWN)
++emsg_off; buf = curbuf;
buf = tv_get_buf(&argvars[0], FALSE); else
--emsg_off; {
(void)tv_get_number(&argvars[0]); // issue errmsg if type error
++emsg_off;
buf = tv_get_buf(&argvars[0], FALSE);
--emsg_off;
}
if (buf == NULL) if (buf == NULL)
return; return;

View File

@@ -22,7 +22,7 @@ func Test_setbufline_getbufline()
call assert_equal(1, setbufline(b, 5, ['x'])) call assert_equal(1, setbufline(b, 5, ['x']))
call assert_equal(1, setbufline(bufnr('$') + 1, 1, ['x'])) call assert_equal(1, setbufline(bufnr('$') + 1, 1, ['x']))
call assert_equal(0, setbufline(b, 4, ['d', 'e'])) call assert_equal(0, setbufline(b, 4, ['d', 'e']))
call assert_equal(['c'], getbufline(b, 3)) call assert_equal(['c'], b->getbufline(3))
call assert_equal(['d'], getbufline(b, 4)) call assert_equal(['d'], getbufline(b, 4))
call assert_equal(['e'], getbufline(b, 5)) call assert_equal(['e'], getbufline(b, 5))
call assert_equal([], getbufline(b, 6)) call assert_equal([], getbufline(b, 6))

View File

@@ -88,7 +88,7 @@ function Test_getbufwintabinfo()
call assert_equal(2, tablist[1].tabnr) call assert_equal(2, tablist[1].tabnr)
call assert_equal('build', tablist[0].variables.space) call assert_equal('build', tablist[0].variables.space)
call assert_equal(w2_id, tablist[0].windows[0]) call assert_equal(w2_id, tablist[0].windows[0])
call assert_equal([], gettabinfo(3)) call assert_equal([], 3->gettabinfo())
tabonly | only tabonly | only
@@ -106,7 +106,7 @@ function Test_getbufwintabinfo()
endfunction endfunction
function Test_get_buf_options() function Test_get_buf_options()
let opts = getbufvar(bufnr('%'), '&') let opts = bufnr()->getbufvar('&')
call assert_equal(v:t_dict, type(opts)) call assert_equal(v:t_dict, type(opts))
call assert_equal(8, opts.tabstop) call assert_equal(8, opts.tabstop)
endfunc endfunc

View File

@@ -83,7 +83,7 @@ func Test_chdir_func()
tabfirst tabfirst
call chdir('..') call chdir('..')
call assert_equal('y', fnamemodify(getcwd(1, 2), ':t')) call assert_equal('y', fnamemodify(getcwd(1, 2), ':t'))
call assert_equal('z', fnamemodify(getcwd(3, 2), ':t')) call assert_equal('z', fnamemodify(3->getcwd(2), ':t'))
tabnext | wincmd t tabnext | wincmd t
eval '..'->chdir() eval '..'->chdir()
call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t')) call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t'))

View File

@@ -8,8 +8,8 @@ func Test_getchangelist()
bwipe! bwipe!
enew enew
call assert_equal([], getchangelist(10)) call assert_equal([], 10->getchangelist())
call assert_equal([[], 0], getchangelist('%')) call assert_equal([[], 0], getchangelist())
call writefile(['line1', 'line2', 'line3'], 'Xfile1.txt') call writefile(['line1', 'line2', 'line3'], 'Xfile1.txt')
call writefile(['line1', 'line2', 'line3'], 'Xfile2.txt') call writefile(['line1', 'line2', 'line3'], 'Xfile2.txt')

View File

@@ -209,7 +209,7 @@ func Test_getcompletion()
endif endif
let groupcount = len(getcompletion('', 'event')) let groupcount = len(getcompletion('', 'event'))
call assert_true(groupcount > 0) call assert_true(groupcount > 0)
let matchcount = len(getcompletion('File', 'event')) let matchcount = len('File'->getcompletion('event'))
call assert_true(matchcount > 0) call assert_true(matchcount > 0)
call assert_true(groupcount > matchcount) call assert_true(groupcount > matchcount)

View File

@@ -199,11 +199,11 @@ func Test_edit_07()
endfu endfu
au InsertCharPre <buffer> :call DoIt() au InsertCharPre <buffer> :call DoIt()
call feedkeys("A\<f5>\<c-p>u\<cr>\<c-l>\<cr>", 'tx') call feedkeys("A\<f5>\<c-p>u\<cr>\<c-l>\<cr>", 'tx')
call assert_equal(["Jan\<c-l>",''], getline(1,'$')) call assert_equal(["Jan\<c-l>",''], 1->getline('$'))
%d %d
call setline(1, 'J') call setline(1, 'J')
call feedkeys("A\<f5>\<c-p>u\<down>\<c-l>\<cr>", 'tx') call feedkeys("A\<f5>\<c-p>u\<down>\<c-l>\<cr>", 'tx')
call assert_equal(["January"], getline(1,'$')) call assert_equal(["January"], 1->getline('$'))
delfu ListMonths delfu ListMonths
delfu DoIt delfu DoIt
@@ -345,7 +345,7 @@ func Test_edit_12()
call cursor(2, 4) call cursor(2, 4)
call feedkeys("R^\<c-d>", 'tnix') call feedkeys("R^\<c-d>", 'tnix')
call assert_equal(["\tabc", "def"], getline(1, '$')) call assert_equal(["\tabc", "def"], getline(1, '$'))
call assert_equal([0, 2, 2, 0], getpos('.')) call assert_equal([0, 2, 2, 0], '.'->getpos())
%d %d
call setline(1, ["\tabc", "\t\tdef"]) call setline(1, ["\tabc", "\t\tdef"])
call cursor(2, 2) call cursor(2, 2)

View File

@@ -11,7 +11,7 @@ endfunc
func Test_getenv() func Test_getenv()
unlet! $TESTENV unlet! $TESTENV
call assert_equal(v:null, getenv('TESTENV')) call assert_equal(v:null, 'TESTENV'->getenv())
let $TESTENV = 'foo' let $TESTENV = 'foo'
call assert_equal('foo', getenv('TESTENV')) call assert_equal('foo', getenv('TESTENV'))
endfunc endfunc

View File

@@ -2,10 +2,10 @@
func Test_file_perm() func Test_file_perm()
call assert_equal('', getfperm('Xtest')) call assert_equal('', getfperm('Xtest'))
call assert_equal(0, setfperm('Xtest', 'r--------')) call assert_equal(0, 'Xtest'->setfperm('r--------'))
call writefile(['one'], 'Xtest') call writefile(['one'], 'Xtest')
call assert_true(len(getfperm('Xtest')) == 9) call assert_true(len('Xtest'->getfperm()) == 9)
call assert_equal(1, setfperm('Xtest', 'rwx------')) call assert_equal(1, setfperm('Xtest', 'rwx------'))
if has('win32') if has('win32')

View File

@@ -31,7 +31,7 @@ func Test_var()
let t:other = 777 let t:other = 777
let def_list = [4, 5, 6, 7] let def_list = [4, 5, 6, 7]
tabrewind tabrewind
call assert_equal([1, 2, 3], gettabvar(3, 'var_list')) call assert_equal([1, 2, 3], 3->gettabvar('var_list'))
call assert_equal([1, 2, 3], gettabvar(3, 'var_list', def_list)) call assert_equal([1, 2, 3], gettabvar(3, 'var_list', def_list))
call assert_equal({'var_list': [1, 2, 3], 'other': 777}, gettabvar(3, '')) call assert_equal({'var_list': [1, 2, 3], 'other': 777}, gettabvar(3, ''))
call assert_equal({'var_list': [1, 2, 3], 'other': 777}, call assert_equal({'var_list': [1, 2, 3], 'other': 777},
@@ -61,7 +61,7 @@ func Test_var()
let def_dict = {'dict2': 'newval'} let def_dict = {'dict2': 'newval'}
wincmd b wincmd b
tabrewind tabrewind
call assert_equal({'dict': 'tabwin'}, gettabwinvar(2, 3, 'var_dict')) call assert_equal({'dict': 'tabwin'}, 2->gettabwinvar(3, 'var_dict'))
call assert_equal({'dict': 'tabwin'}, call assert_equal({'dict': 'tabwin'},
\ gettabwinvar(2, 3, 'var_dict', def_dict)) \ gettabwinvar(2, 3, 'var_dict', def_dict))
call assert_equal({'var_dict': {'dict': 'tabwin'}}, gettabwinvar(2, 3, '')) call assert_equal({'var_dict': {'dict': 'tabwin'}}, gettabwinvar(2, 3, ''))

View File

@@ -39,7 +39,7 @@ func Test_getjumplist()
" Traverse the jump list and verify the results " Traverse the jump list and verify the results
5 5
exe "normal \<C-O>" exe "normal \<C-O>"
call assert_equal(2, getjumplist(1)[1]) call assert_equal(2, 1->getjumplist()[1])
exe "normal 2\<C-O>" exe "normal 2\<C-O>"
call assert_equal(0, getjumplist(1, 1)[1]) call assert_equal(0, getjumplist(1, 1)[1])
exe "normal 3\<C-I>" exe "normal 3\<C-I>"

View File

@@ -22,7 +22,7 @@ endfunc
func Test_put_char_block2() func Test_put_char_block2()
new new
let a = [ getreg('a'), getregtype('a') ] let a = [ 'a'->getreg(), 'a'->getregtype() ]
call setreg('a', ' one ', 'v') call setreg('a', ' one ', 'v')
call setline(1, ['Line 1', '', 'Line 3', '']) call setline(1, ['Line 1', '', 'Line 3', ''])
" visually select the first 3 lines and put register a over it " visually select the first 3 lines and put register a over it

View File

@@ -10,7 +10,7 @@ func CheckFileTime(doSleep)
let fl = ['Hello World!'] let fl = ['Hello World!']
for fname in fnames for fname in fnames
call writefile(fl, fname) call writefile(fl, fname)
call add(times, getftime(fname)) call add(times, fname->getftime())
if a:doSleep if a:doSleep
sleep 1 sleep 1
endif endif
@@ -19,8 +19,8 @@ func CheckFileTime(doSleep)
let time_correct = (times[0] <= times[1] && times[1] <= times[2]) let time_correct = (times[0] <= times[1] && times[1] <= times[2])
if a:doSleep || time_correct if a:doSleep || time_correct
call assert_true(time_correct, printf('Expected %s <= %s <= %s', times[0], times[1], times[2])) call assert_true(time_correct, printf('Expected %s <= %s <= %s', times[0], times[1], times[2]))
call assert_equal(strlen(fl[0] . "\n"), getfsize(fnames[0])) call assert_equal(strlen(fl[0] . "\n"), fnames[0]->getfsize())
call assert_equal('file', getftype(fnames[0])) call assert_equal('file', fnames[0]->getftype())
call assert_equal('rw-', getfperm(fnames[0])[0:2]) call assert_equal('rw-', getfperm(fnames[0])[0:2])
let result = 1 let result = 1
endif endif

View File

@@ -761,6 +761,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1925,
/**/ /**/
1924, 1924,
/**/ /**/