mirror of
https://github.com/neovim/neovim.git
synced 2025-10-09 19:36:40 +00:00
vim-patch:8.1.1610: there is no way to add or load a buffer without side effects
Problem: There is no way to add or load a buffer without side effects.
Solution: Add the bufadd() and bufload() functions.
15e248e37f
This commit is contained in:
@@ -1188,3 +1188,31 @@ func Test_libcall_libcallnr()
|
||||
call assert_fails("call libcall('Xdoesnotexist_', 'getenv', 'HOME')", 'E364:')
|
||||
call assert_fails("call libcallnr('Xdoesnotexist_', 'strlen', 'abcd')", 'E364:')
|
||||
endfunc
|
||||
|
||||
func Test_bufadd_bufload()
|
||||
call assert_equal(0, bufexists('someName'))
|
||||
let buf = bufadd('someName')
|
||||
call assert_notequal(0, buf)
|
||||
call assert_equal(1, bufexists('someName'))
|
||||
call assert_equal(0, getbufvar(buf, '&buflisted'))
|
||||
call assert_equal(0, bufloaded(buf))
|
||||
call bufload(buf)
|
||||
call assert_equal(1, bufloaded(buf))
|
||||
call assert_equal([''], getbufline(buf, 1, '$'))
|
||||
|
||||
let curbuf = bufnr('')
|
||||
call writefile(['some', 'text'], 'otherName')
|
||||
let buf = bufadd('otherName')
|
||||
call assert_notequal(0, buf)
|
||||
call assert_equal(1, bufexists('otherName'))
|
||||
call assert_equal(0, getbufvar(buf, '&buflisted'))
|
||||
call assert_equal(0, bufloaded(buf))
|
||||
call bufload(buf)
|
||||
call assert_equal(1, bufloaded(buf))
|
||||
call assert_equal(['some', 'text'], getbufline(buf, 1, '$'))
|
||||
call assert_equal(curbuf, bufnr(''))
|
||||
|
||||
bwipe someName
|
||||
bwipe otherName
|
||||
call assert_equal(0, bufexists('someName'))
|
||||
endfunc
|
||||
|
Reference in New Issue
Block a user