mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 23:31:51 +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.
|
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
|
||||||
@@ -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.
|
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
|
||||||
|
@@ -83,6 +83,9 @@ assert_equalfile({fname-one}, {fname-two})
|
|||||||
When {fname-one} or {fname-two} does not exist the error will
|
When {fname-one} or {fname-two} does not exist the error will
|
||||||
mention that.
|
mention that.
|
||||||
|
|
||||||
|
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|.
|
||||||
@@ -172,10 +175,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()|.
|
||||||
|
@@ -35,7 +35,7 @@ return {
|
|||||||
asin={args=1, base=1, func="float_op_wrapper", data="&asin"}, -- WJMc
|
asin={args=1, base=1, func="float_op_wrapper", data="&asin"}, -- WJMc
|
||||||
assert_beeps={args={1}, base=1},
|
assert_beeps={args={1}, base=1},
|
||||||
assert_equal={args={2, 3}, base=2},
|
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_exception={args={1, 2}},
|
||||||
assert_fails={args={1, 3}, base=1},
|
assert_fails={args={1, 3}, base=1},
|
||||||
assert_false={args={1, 2}, base=1},
|
assert_false={args={1, 2}, base=1},
|
||||||
@@ -44,7 +44,7 @@ return {
|
|||||||
assert_nobeep={args={1}},
|
assert_nobeep={args={1}},
|
||||||
assert_notequal={args={2, 3}, base=2},
|
assert_notequal={args={2, 3}, base=2},
|
||||||
assert_notmatch={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},
|
assert_true={args={1, 2}, base=1},
|
||||||
atan={args=1, base=1, func="float_op_wrapper", data="&atan"},
|
atan={args=1, base=1, func="float_op_wrapper", data="&atan"},
|
||||||
atan2={args=2, base=1},
|
atan2={args=2, base=1},
|
||||||
@@ -60,8 +60,8 @@ return {
|
|||||||
bufloaded={args=1, base=1},
|
bufloaded={args=1, base=1},
|
||||||
bufname={args={0, 1}, base=1},
|
bufname={args={0, 1}, base=1},
|
||||||
bufnr={args={0, 2}, base=1},
|
bufnr={args={0, 2}, base=1},
|
||||||
bufwinid={args=1},
|
bufwinid={args=1, base=1},
|
||||||
bufwinnr={args=1},
|
bufwinnr={args=1, base=1},
|
||||||
byte2line={args=1},
|
byte2line={args=1},
|
||||||
byteidx={args=2},
|
byteidx={args=2},
|
||||||
byteidxcomp={args=2},
|
byteidxcomp={args=2},
|
||||||
@@ -408,7 +408,7 @@ return {
|
|||||||
win_id2win={args=1},
|
win_id2win={args=1},
|
||||||
win_screenpos={args=1},
|
win_screenpos={args=1},
|
||||||
win_splitmove={args={2, 3}},
|
win_splitmove={args={2, 3}},
|
||||||
winbufnr={args=1},
|
winbufnr={args=1, base=1},
|
||||||
wincol={},
|
wincol={},
|
||||||
windowsversion={},
|
windowsversion={},
|
||||||
winheight={args=1},
|
winheight={args=1},
|
||||||
|
@@ -7,7 +7,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)
|
||||||
|
|
||||||
|
@@ -131,11 +131,11 @@ func Test_appendbufline_redraw()
|
|||||||
endif
|
endif
|
||||||
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})))
|
||||||
|
@@ -360,6 +360,13 @@ describe('assert function:', function()
|
|||||||
command('call remove(v:errors, 0)')
|
command('call remove(v:errors, 0)')
|
||||||
expected_empty()
|
expected_empty()
|
||||||
end)
|
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)
|
end)
|
||||||
|
|
||||||
-- assert_exception({cmd}, [, {error}])
|
-- assert_exception({cmd}, [, {error}])
|
||||||
|
Reference in New Issue
Block a user