buf_T *curbuf_save;
int is_curbuf = buf == curbuf;
- if (buf == NULL || buf->b_ml.ml_mfp == NULL || lnum < 1)
+ /* When using the current buffer ml_mfp will be set if needed. Useful when
+ * setline() is used on startup. For other buffers the buffer must be
+ * loaded. */
+ if (buf == NULL || (!is_curbuf && buf->b_ml.ml_mfp == NULL) || lnum < 1)
{
rettv->vval.v_number = 1; /* FAIL */
return;
endfunc
" Get the command to run Vim, with -u NONE and --not-a-term arguments.
+" If there is an argument use it instead of "NONE".
" Returns an empty string on error.
-func GetVimCommand()
+func GetVimCommand(...)
if !filereadable('vimcmd')
return ''
endif
+ if a:0 == 0
+ let name = 'NONE'
+ else
+ let name = a:1
+ endif
let cmd = readfile('vimcmd')[0]
- let cmd = substitute(cmd, '-u \f\+', '-u NONE', '')
- if cmd !~ '-u NONE'
- let cmd = cmd . ' -u NONE'
+ let cmd = substitute(cmd, '-u \f\+', '-u ' . name, '')
+ if cmd !~ '-u '. name
+ let cmd = cmd . ' -u ' . name
endif
let cmd .= ' --not-a-term'
let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '')
" A series of tests that can run in one Vim invocation.
" This makes testing go faster, since Vim doesn't need to restart.
+source shared.vim
+
set belloff=all
source test_assign.vim
source test_bufline.vim
call assert_equal([], getbufline(b, 6))
exe "bwipe! " . b
endfunc
+
+func Test_setline_startup()
+ let cmd = GetVimCommand('Xscript')
+ if cmd == ''
+ return
+ endif
+ call writefile(['call setline(1, "Hello")', 'w Xtest', 'q!'], 'Xscript')
+ call system(cmd)
+ call assert_equal(['Hello'], readfile('Xtest'))
+
+ call delete('Xscript')
+ call delete('Xtest')
+endfunc
" Test for timers
-source shared.vim
-
if !has('timers')
finish
endif
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1053,
/**/
1052,
/**/