mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-24 06:30:03 +08:00
26 lines
1.4 KiB
Plaintext
26 lines
1.4 KiB
Plaintext
Execute ( SpaceVim api: vim#buffer open ):
|
|
let buffer = SpaceVim#api#import('vim#buffer')
|
|
call buffer.open({'bufname':'foo', 'cmd' : 'setl buftype=nofile bufhidden=wipe'})
|
|
AssertEqual bufname('%'), 'foo'
|
|
AssertEqual &buftype, 'nofile'
|
|
|
|
Execute ( SpaceVim api: vim#buffer buf_set_lines):
|
|
let buffer = SpaceVim#api#import('vim#buffer')
|
|
let nr = buffer.bufadd('')
|
|
call setbufvar(nr, '&buftype', 'nofile')
|
|
call setbufvar(nr, '&buflisted', 0)
|
|
Log 'The value of g:_spacevim_if_lua is ' . get(g:, '_spacevim_if_lua', 0)
|
|
call buffer.buf_set_lines(nr, 0, 1, 0, ['line 1', 'line 2', 'line 3', 'line 4'])
|
|
AssertEqual getbufline(nr, 1, '$'), ['line 1', 'line 2', 'line 3', 'line 4']
|
|
call buffer.buf_set_lines(nr, 1, 3, 0, ['replace 1', 'replace 2', 'replace 3'])
|
|
AssertEqual getbufline(nr, 1, '$'), ['line 1', 'replace 1', 'replace 2', 'replace 3', 'line 4']
|
|
call buffer.buf_set_lines(nr, -3, -1, 0, ['replace 1', 'replace 2', 'replace 3'])
|
|
AssertEqual getbufline(nr, 1, '$'), ['line 1', 'replace 1', 'replace 2', 'replace 1', 'replace 2', 'replace 3']
|
|
call buffer.buf_set_lines(nr, 2, -2, 0, ['replace 1', 'replace 2', 'replace 3'])
|
|
AssertEqual getbufline(nr, 1, '$'), ['line 1', 'replace 1', 'replace 1', 'replace 2', 'replace 3', 'replace 3']
|
|
call buffer.buf_set_lines(nr, 0, -1, 0, ['xx 1'])
|
|
AssertEqual getbufline(nr, 1, '$'), ['xx 1']
|
|
exe 'bd!' nr
|
|
unlet nr
|
|
unlet buffer
|