forked from aniani/vim
patch 8.1.1909: more functions can be used as methods
Problem: More functions can be used as methods. Solution: Make a few more functions usable as a method.
This commit is contained in:
parent
00b0d6d8dc
commit
e49fbff384
@ -1,4 +1,4 @@
|
|||||||
*eval.txt* For Vim version 8.1. Last change: 2019 Aug 18
|
*eval.txt* For Vim version 8.1. Last change: 2019 Aug 21
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -2593,9 +2593,10 @@ popup_create({what}, {options}) Number create a popup window
|
|||||||
popup_dialog({what}, {options}) Number create a popup window used as a dialog
|
popup_dialog({what}, {options}) Number create a popup window used as a dialog
|
||||||
popup_filter_menu({id}, {key}) Number filter for a menu popup window
|
popup_filter_menu({id}, {key}) Number filter for a menu popup window
|
||||||
popup_filter_yesno({id}, {key}) Number filter for a dialog popup window
|
popup_filter_yesno({id}, {key}) Number filter for a dialog popup window
|
||||||
|
popup_findinfo() Number get window ID of info popup window
|
||||||
|
popup_findpreview() Number get window ID of preview popup window
|
||||||
popup_getoptions({id}) Dict get options of popup window {id}
|
popup_getoptions({id}) Dict get options of popup window {id}
|
||||||
popup_getpos({id}) Dict get position of popup window {id}
|
popup_getpos({id}) Dict get position of popup window {id}
|
||||||
popup_getpreview() Number get window ID of preview popup window
|
|
||||||
popup_hide({id}) none hide popup menu {id}
|
popup_hide({id}) none hide popup menu {id}
|
||||||
popup_menu({what}, {options}) Number create a popup window used as a menu
|
popup_menu({what}, {options}) Number create a popup window used as a menu
|
||||||
popup_move({id}, {options}) none set position of popup window {id}
|
popup_move({id}, {options}) none set position of popup window {id}
|
||||||
@ -3274,17 +3275,22 @@ bufwinid({expr}) *bufwinid()*
|
|||||||
<
|
<
|
||||||
Only deals with the current tab page.
|
Only deals with the current tab page.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
FindBuffer()->bufwinid()
|
||||||
|
|
||||||
bufwinnr({expr}) *bufwinnr()*
|
bufwinnr({expr}) *bufwinnr()*
|
||||||
The result is a Number, which is the number of the first
|
Like |bufwinid()| but return the window number instead of the
|
||||||
window associated with buffer {expr}. For the use of {expr},
|
|window-ID|.
|
||||||
see |bufname()| above. If buffer {expr} doesn't exist or
|
If buffer {expr} doesn't exist or there is no such window, -1
|
||||||
there is no such window, -1 is returned. Example: >
|
is returned. Example: >
|
||||||
|
|
||||||
echo "A window containing buffer 1 is " . (bufwinnr(1))
|
echo "A window containing buffer 1 is " . (bufwinnr(1))
|
||||||
|
|
||||||
< The number can be used with |CTRL-W_w| and ":wincmd w"
|
< The number can be used with |CTRL-W_w| and ":wincmd w"
|
||||||
|:wincmd|.
|
|:wincmd|.
|
||||||
Only deals with the current tab page.
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
FindBuffer()->bufwinnr()
|
||||||
|
|
||||||
byte2line({byte}) *byte2line()*
|
byte2line({byte}) *byte2line()*
|
||||||
Return the line number that contains the character at byte
|
Return the line number that contains the character at byte
|
||||||
@ -9511,6 +9517,9 @@ winbufnr({nr}) The result is a Number, which is the number of the buffer
|
|||||||
When window {nr} doesn't exist, -1 is returned.
|
When window {nr} doesn't exist, -1 is returned.
|
||||||
Example: >
|
Example: >
|
||||||
:echo "The file in the current window is " . bufname(winbufnr(0))
|
:echo "The file in the current window is " . bufname(winbufnr(0))
|
||||||
|
<
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
FindWindow()->winbufnr()->bufname()
|
||||||
<
|
<
|
||||||
*wincol()*
|
*wincol()*
|
||||||
wincol() The result is a Number, which is the virtual column of the
|
wincol() The result is a Number, which is the virtual column of the
|
||||||
@ -9823,7 +9832,7 @@ hangul_input Compiled with Hangul input support. |hangul|
|
|||||||
hpux HP-UX version of Vim.
|
hpux HP-UX version of Vim.
|
||||||
iconv Can use iconv() for conversion.
|
iconv Can use iconv() for conversion.
|
||||||
insert_expand Compiled with support for CTRL-X expansion commands in
|
insert_expand Compiled with support for CTRL-X expansion commands in
|
||||||
Insert mode.
|
Insert mode. (always true)
|
||||||
jumplist Compiled with |jumplist| support.
|
jumplist Compiled with |jumplist| support.
|
||||||
keymap Compiled with 'keymap' support.
|
keymap Compiled with 'keymap' support.
|
||||||
lambda Compiled with |lambda| support.
|
lambda Compiled with |lambda| support.
|
||||||
|
@ -238,6 +238,10 @@ assert_equalfile({fname-one}, {fname-two})
|
|||||||
mention that.
|
mention that.
|
||||||
Mainly useful with |terminal-diff|.
|
Mainly useful with |terminal-diff|.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetLog()->assert_equalfile('expected.log')
|
||||||
|
|
||||||
|
|
||||||
assert_exception({error} [, {msg}]) *assert_exception()*
|
assert_exception({error} [, {msg}]) *assert_exception()*
|
||||||
When v:exception does not contain the string {error} an error
|
When v:exception does not contain the string {error} an error
|
||||||
message is added to |v:errors|. Also see |assert-return|.
|
message is added to |v:errors|. Also see |assert-return|.
|
||||||
@ -322,10 +326,15 @@ assert_notmatch({pattern}, {actual} [, {msg}])
|
|||||||
Can also be used as a |method|: >
|
Can also be used as a |method|: >
|
||||||
getFile()->assert_notmatch('bar.*')
|
getFile()->assert_notmatch('bar.*')
|
||||||
|
|
||||||
|
|
||||||
assert_report({msg}) *assert_report()*
|
assert_report({msg}) *assert_report()*
|
||||||
Report a test failure directly, using {msg}.
|
Report a test failure directly, using {msg}.
|
||||||
Always returns one.
|
Always returns one.
|
||||||
|
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetMessage()->assert_report()
|
||||||
|
|
||||||
|
|
||||||
assert_true({actual} [, {msg}]) *assert_true()*
|
assert_true({actual} [, {msg}]) *assert_true()*
|
||||||
When {actual} is not true an error message is added to
|
When {actual} is not true an error message is added to
|
||||||
|v:errors|, like with |assert_equal()|.
|
|v:errors|, like with |assert_equal()|.
|
||||||
|
@ -431,7 +431,7 @@ static funcentry_T global_functions[] =
|
|||||||
#endif
|
#endif
|
||||||
{"assert_beeps", 1, 2, FEARG_1, f_assert_beeps},
|
{"assert_beeps", 1, 2, FEARG_1, f_assert_beeps},
|
||||||
{"assert_equal", 2, 3, FEARG_2, f_assert_equal},
|
{"assert_equal", 2, 3, FEARG_2, f_assert_equal},
|
||||||
{"assert_equalfile", 2, 2, 0, f_assert_equalfile},
|
{"assert_equalfile", 2, 2, FEARG_1, f_assert_equalfile},
|
||||||
{"assert_exception", 1, 2, 0, f_assert_exception},
|
{"assert_exception", 1, 2, 0, f_assert_exception},
|
||||||
{"assert_fails", 1, 3, FEARG_1, f_assert_fails},
|
{"assert_fails", 1, 3, FEARG_1, f_assert_fails},
|
||||||
{"assert_false", 1, 2, FEARG_1, f_assert_false},
|
{"assert_false", 1, 2, FEARG_1, f_assert_false},
|
||||||
@ -439,7 +439,7 @@ static funcentry_T global_functions[] =
|
|||||||
{"assert_match", 2, 3, FEARG_2, f_assert_match},
|
{"assert_match", 2, 3, FEARG_2, f_assert_match},
|
||||||
{"assert_notequal", 2, 3, FEARG_2, f_assert_notequal},
|
{"assert_notequal", 2, 3, FEARG_2, f_assert_notequal},
|
||||||
{"assert_notmatch", 2, 3, FEARG_2, f_assert_notmatch},
|
{"assert_notmatch", 2, 3, FEARG_2, f_assert_notmatch},
|
||||||
{"assert_report", 1, 1, 0, f_assert_report},
|
{"assert_report", 1, 1, FEARG_1, f_assert_report},
|
||||||
{"assert_true", 1, 2, FEARG_1, f_assert_true},
|
{"assert_true", 1, 2, FEARG_1, f_assert_true},
|
||||||
#ifdef FEAT_FLOAT
|
#ifdef FEAT_FLOAT
|
||||||
{"atan", 1, 1, FEARG_1, f_atan},
|
{"atan", 1, 1, FEARG_1, f_atan},
|
||||||
@ -464,8 +464,8 @@ static funcentry_T global_functions[] =
|
|||||||
{"bufloaded", 1, 1, FEARG_1, f_bufloaded},
|
{"bufloaded", 1, 1, FEARG_1, f_bufloaded},
|
||||||
{"bufname", 1, 1, FEARG_1, f_bufname},
|
{"bufname", 1, 1, FEARG_1, f_bufname},
|
||||||
{"bufnr", 1, 2, FEARG_1, f_bufnr},
|
{"bufnr", 1, 2, FEARG_1, f_bufnr},
|
||||||
{"bufwinid", 1, 1, 0, f_bufwinid},
|
{"bufwinid", 1, 1, FEARG_1, f_bufwinid},
|
||||||
{"bufwinnr", 1, 1, 0, f_bufwinnr},
|
{"bufwinnr", 1, 1, FEARG_1, f_bufwinnr},
|
||||||
{"byte2line", 1, 1, 0, f_byte2line},
|
{"byte2line", 1, 1, 0, f_byte2line},
|
||||||
{"byteidx", 2, 2, 0, f_byteidx},
|
{"byteidx", 2, 2, 0, f_byteidx},
|
||||||
{"byteidxcomp", 2, 2, 0, f_byteidxcomp},
|
{"byteidxcomp", 2, 2, 0, f_byteidxcomp},
|
||||||
@ -963,7 +963,7 @@ static funcentry_T global_functions[] =
|
|||||||
{"win_id2tabwin", 1, 1, 0, f_win_id2tabwin},
|
{"win_id2tabwin", 1, 1, 0, f_win_id2tabwin},
|
||||||
{"win_id2win", 1, 1, 0, f_win_id2win},
|
{"win_id2win", 1, 1, 0, f_win_id2win},
|
||||||
{"win_screenpos", 1, 1, 0, f_win_screenpos},
|
{"win_screenpos", 1, 1, 0, f_win_screenpos},
|
||||||
{"winbufnr", 1, 1, 0, f_winbufnr},
|
{"winbufnr", 1, 1, FEARG_1, f_winbufnr},
|
||||||
{"wincol", 0, 0, 0, f_wincol},
|
{"wincol", 0, 0, 0, f_wincol},
|
||||||
{"winheight", 1, 1, 0, f_winheight},
|
{"winheight", 1, 1, 0, f_winheight},
|
||||||
{"winlayout", 0, 1, 0, f_winlayout},
|
{"winlayout", 0, 1, 0, f_winlayout},
|
||||||
|
@ -54,7 +54,7 @@ func Test_assert_equalfile()
|
|||||||
|
|
||||||
let goodtext = ["one", "two", "three"]
|
let goodtext = ["one", "two", "three"]
|
||||||
call writefile(goodtext, 'Xone')
|
call writefile(goodtext, 'Xone')
|
||||||
call assert_equal(1, assert_equalfile('Xone', 'xyzxyz'))
|
call assert_equal(1, 'Xone'->assert_equalfile('xyzxyz'))
|
||||||
call assert_match("E485: Can't read file xyzxyz", v:errors[0])
|
call assert_match("E485: Can't read file xyzxyz", v:errors[0])
|
||||||
call remove(v:errors, 0)
|
call remove(v:errors, 0)
|
||||||
|
|
||||||
@ -97,6 +97,9 @@ func Test_assert_report()
|
|||||||
call assert_equal(1, assert_report('something is wrong'))
|
call assert_equal(1, assert_report('something is wrong'))
|
||||||
call assert_match('something is wrong', v:errors[0])
|
call assert_match('something is wrong', v:errors[0])
|
||||||
call remove(v:errors, 0)
|
call remove(v:errors, 0)
|
||||||
|
call assert_equal(1, 'also wrong'->assert_report())
|
||||||
|
call assert_match('also wrong', v:errors[0])
|
||||||
|
call remove(v:errors, 0)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_assert_exception()
|
func Test_assert_exception()
|
||||||
|
@ -152,11 +152,11 @@ func Test_appendbufline_redraw()
|
|||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
new foo
|
new foo
|
||||||
let winnr=bufwinnr('foo')
|
let winnr = 'foo'->bufwinnr()
|
||||||
let buf = bufnr('foo')
|
let buf = bufnr('foo')
|
||||||
wincmd p
|
wincmd p
|
||||||
call appendbufline(buf, '$', range(1,200))
|
call appendbufline(buf, '$', range(1,200))
|
||||||
exe winnr. 'wincmd w'
|
exe winnr .. 'wincmd w'
|
||||||
norm! G
|
norm! G
|
||||||
wincmd p
|
wincmd p
|
||||||
call deletebufline(buf, 1, '$')
|
call deletebufline(buf, 1, '$')
|
||||||
|
@ -18,7 +18,7 @@ function Test_getbufwintabinfo()
|
|||||||
let l = getbufinfo('%')
|
let l = getbufinfo('%')
|
||||||
call assert_equal(bufnr('%'), l[0].bufnr)
|
call assert_equal(bufnr('%'), l[0].bufnr)
|
||||||
call assert_equal('vim', l[0].variables.editor)
|
call assert_equal('vim', l[0].variables.editor)
|
||||||
call assert_notequal(-1, index(l[0].windows, bufwinid('%')))
|
call assert_notequal(-1, index(l[0].windows, '%'->bufwinid()))
|
||||||
|
|
||||||
" Test for getbufinfo() with 'bufmodified'
|
" Test for getbufinfo() with 'bufmodified'
|
||||||
call assert_equal(0, len(getbufinfo({'bufmodified' : 1})))
|
call assert_equal(0, len(getbufinfo({'bufmodified' : 1})))
|
||||||
|
@ -2332,8 +2332,7 @@ func Test_popupmenu_info_align_menu()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_popupwin_recycle_bnr()
|
func Test_popupwin_recycle_bnr()
|
||||||
let winid = popup_notification('nothing wrong', {})
|
let bufnr = popup_notification('nothing wrong', {})->winbufnr()
|
||||||
let bufnr = winbufnr(winid)
|
|
||||||
call popup_clear()
|
call popup_clear()
|
||||||
let winid = popup_notification('nothing wrong', {})
|
let winid = popup_notification('nothing wrong', {})
|
||||||
call assert_equal(bufnr, winbufnr(winid))
|
call assert_equal(bufnr, winbufnr(winid))
|
||||||
|
@ -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 */
|
||||||
|
/**/
|
||||||
|
1909,
|
||||||
/**/
|
/**/
|
||||||
1908,
|
1908,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user