2017-10-05 22:27:10 +08:00
|
|
|
Execute ( SpaceVim api: vim#buffer open ):
|
2017-05-07 23:34:27 +08:00
|
|
|
let buffer = SpaceVim#api#import('vim#buffer')
|
|
|
|
call buffer.open({'bufname':'foo', 'cmd' : 'setl buftype=nofile bufhidden=wipe'})
|
|
|
|
AssertEqual bufname('%'), 'foo'
|
|
|
|
AssertEqual &buftype, 'nofile'
|
2017-10-05 22:27:10 +08:00
|
|
|
|
|
|
|
Execute ( SpaceVim api: vim#buffer buf_set_lines):
|
|
|
|
let buffer = SpaceVim#api#import('vim#buffer')
|
2020-01-19 18:35:50 +08:00
|
|
|
let nr = buffer.bufadd('')
|
2019-10-11 23:07:03 +08:00
|
|
|
call setbufvar(nr, '&buftype', 'nofile')
|
|
|
|
call setbufvar(nr, '&buflisted', 0)
|
2020-08-29 16:46:57 +08:00
|
|
|
Log 'The value of g:_spacevim_if_lua is ' . get(g:, '_spacevim_if_lua', 0)
|
2019-10-11 23:07:03 +08:00
|
|
|
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']
|
2020-07-15 22:25:28 +08:00
|
|
|
call buffer.buf_set_lines(nr, 0, -1, 0, ['xx 1'])
|
|
|
|
AssertEqual getbufline(nr, 1, '$'), ['xx 1']
|
2020-01-19 18:35:50 +08:00
|
|
|
exe 'bd!' nr
|
|
|
|
unlet nr
|
|
|
|
unlet buffer
|
2020-09-16 21:56:19 +08:00
|
|
|
|
2020-10-07 13:31:10 +08:00
|
|
|
Execute ( SpaceVim api: vim#buffer buf_get_lines):
|
|
|
|
let buffer = SpaceVim#api#import('vim#buffer')
|
|
|
|
let nr = buffer.bufadd('')
|
|
|
|
call setbufvar(nr, '&buftype', 'nofile')
|
|
|
|
call setbufvar(nr, '&buflisted', 0)
|
|
|
|
call buffer.buf_set_lines(nr, 0, 1, 0, ['line 1', 'line 2', 'line 3', 'line 4'])
|
2020-10-15 13:08:59 +08:00
|
|
|
if has('patch-8.1.1610')
|
|
|
|
AssertEqual buffer.buf_get_lines(nr, 1, 2, 0), ['line 2']
|
|
|
|
endif
|