mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 15:21:47 +00:00
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.
e49fbff384
This commit is contained in:
@@ -2929,18 +2929,22 @@ bufwinid({expr}) *bufwinid()*
|
||||
<
|
||||
Only deals with the current tab page.
|
||||
|
||||
Can also be used as a |method|: >
|
||||
FindBuffer()->bufwinid()
|
||||
|
||||
bufwinnr({expr}) *bufwinnr()*
|
||||
The result is a Number, which is the number of the first
|
||||
window associated with buffer {expr}. For the use of {expr},
|
||||
see |bufname()| above. If buffer {expr} doesn't exist or
|
||||
there is no such window, -1 is returned. Example: >
|
||||
Like |bufwinid()| but return the window number instead of the
|
||||
|window-ID|.
|
||||
If buffer {expr} doesn't exist or there is no such window, -1
|
||||
is returned. Example: >
|
||||
|
||||
echo "A window containing buffer 1 is " . (bufwinnr(1))
|
||||
|
||||
< The number can be used with |CTRL-W_w| and ":wincmd w"
|
||||
|:wincmd|.
|
||||
Only deals with the current tab page.
|
||||
|
||||
Can also be used as a |method|: >
|
||||
FindBuffer()->bufwinnr()
|
||||
|
||||
byte2line({byte}) *byte2line()*
|
||||
Return the line number that contains the character at byte
|
||||
@@ -9618,6 +9622,9 @@ winbufnr({nr}) The result is a Number, which is the number of the buffer
|
||||
When window {nr} doesn't exist, -1 is returned.
|
||||
Example: >
|
||||
:echo "The file in the current window is " . bufname(winbufnr(0))
|
||||
<
|
||||
Can also be used as a |method|: >
|
||||
FindWindow()->winbufnr()->bufname()
|
||||
<
|
||||
*wincol()*
|
||||
wincol() The result is a Number, which is the virtual column of the
|
||||
|
@@ -83,6 +83,9 @@ assert_equalfile({fname-one}, {fname-two})
|
||||
When {fname-one} or {fname-two} does not exist the error will
|
||||
mention that.
|
||||
|
||||
Can also be used as a |method|: >
|
||||
GetLog()->assert_equalfile('expected.log')
|
||||
|
||||
assert_exception({error} [, {msg}]) *assert_exception()*
|
||||
When v:exception does not contain the string {error} an error
|
||||
message is added to |v:errors|. Also see |assert-return|.
|
||||
@@ -172,10 +175,15 @@ assert_notmatch({pattern}, {actual} [, {msg}])
|
||||
Can also be used as a |method|: >
|
||||
getFile()->assert_notmatch('bar.*')
|
||||
|
||||
|
||||
assert_report({msg}) *assert_report()*
|
||||
Report a test failure directly, using {msg}.
|
||||
Always returns one.
|
||||
|
||||
Can also be used as a |method|: >
|
||||
GetMessage()->assert_report()
|
||||
|
||||
|
||||
assert_true({actual} [, {msg}]) *assert_true()*
|
||||
When {actual} is not true an error message is added to
|
||||
|v:errors|, like with |assert_equal()|.
|
||||
|
@@ -35,7 +35,7 @@ return {
|
||||
asin={args=1, base=1, func="float_op_wrapper", data="&asin"}, -- WJMc
|
||||
assert_beeps={args={1}, base=1},
|
||||
assert_equal={args={2, 3}, base=2},
|
||||
assert_equalfile={args={2, 3}},
|
||||
assert_equalfile={args={2, 3}, base=1},
|
||||
assert_exception={args={1, 2}},
|
||||
assert_fails={args={1, 3}, base=1},
|
||||
assert_false={args={1, 2}, base=1},
|
||||
@@ -44,7 +44,7 @@ return {
|
||||
assert_nobeep={args={1}},
|
||||
assert_notequal={args={2, 3}, base=2},
|
||||
assert_notmatch={args={2, 3}, base=2},
|
||||
assert_report={args=1},
|
||||
assert_report={args=1, base=1},
|
||||
assert_true={args={1, 2}, base=1},
|
||||
atan={args=1, base=1, func="float_op_wrapper", data="&atan"},
|
||||
atan2={args=2, base=1},
|
||||
@@ -60,8 +60,8 @@ return {
|
||||
bufloaded={args=1, base=1},
|
||||
bufname={args={0, 1}, base=1},
|
||||
bufnr={args={0, 2}, base=1},
|
||||
bufwinid={args=1},
|
||||
bufwinnr={args=1},
|
||||
bufwinid={args=1, base=1},
|
||||
bufwinnr={args=1, base=1},
|
||||
byte2line={args=1},
|
||||
byteidx={args=2},
|
||||
byteidxcomp={args=2},
|
||||
@@ -408,7 +408,7 @@ return {
|
||||
win_id2win={args=1},
|
||||
win_screenpos={args=1},
|
||||
win_splitmove={args={2, 3}},
|
||||
winbufnr={args=1},
|
||||
winbufnr={args=1, base=1},
|
||||
wincol={},
|
||||
windowsversion={},
|
||||
winheight={args=1},
|
||||
|
@@ -7,7 +7,7 @@ func Test_assert_equalfile()
|
||||
|
||||
let goodtext = ["one", "two", "three"]
|
||||
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 remove(v:errors, 0)
|
||||
|
||||
|
@@ -131,11 +131,11 @@ func Test_appendbufline_redraw()
|
||||
endif
|
||||
let lines =<< trim END
|
||||
new foo
|
||||
let winnr=bufwinnr('foo')
|
||||
let buf=bufnr('foo')
|
||||
let winnr = 'foo'->bufwinnr()
|
||||
let buf = bufnr('foo')
|
||||
wincmd p
|
||||
call appendbufline(buf, '$', range(1,200))
|
||||
exe winnr. 'wincmd w'
|
||||
exe winnr .. 'wincmd w'
|
||||
norm! G
|
||||
wincmd p
|
||||
call deletebufline(buf, 1, '$')
|
||||
|
@@ -18,7 +18,7 @@ function Test_getbufwintabinfo()
|
||||
let l = getbufinfo('%')
|
||||
call assert_equal(bufnr('%'), l[0].bufnr)
|
||||
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'
|
||||
call assert_equal(0, len(getbufinfo({'bufmodified' : 1})))
|
||||
|
@@ -360,6 +360,13 @@ describe('assert function:', function()
|
||||
command('call remove(v:errors, 0)')
|
||||
expected_empty()
|
||||
end)
|
||||
|
||||
it('can be used as a method', function()
|
||||
local tmpname = source [[
|
||||
call assert_equal(1, 'also wrong'->assert_report())
|
||||
]]
|
||||
expected_errors({tmpname .. ' line 1: also wrong'})
|
||||
end)
|
||||
end)
|
||||
|
||||
-- assert_exception({cmd}, [, {error}])
|
||||
|
Reference in New Issue
Block a user