To: vim_dev@googlegroups.com Subject: Patch 8.0.1053 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1053 Problem: setline() does not work on startup. (Manuel Ortega) Solution: Do not check for ml_mfp to be set for the current buffer. (Christian Brabandt) Files: src/testdir/shared.vim, src/testdir/test_alot.vim, src/testdir/test_bufline.vim, src/testdir/test_timers.vim, src/evalfunc.c *** ../vim-8.0.1052/src/testdir/shared.vim 2017-08-13 20:26:16.040377374 +0200 --- src/testdir/shared.vim 2017-09-04 20:16:12.585521302 +0200 *************** *** 166,180 **** endfunc " Get the command to run Vim, with -u NONE and --not-a-term arguments. " Returns an empty string on error. ! func GetVimCommand() if !filereadable('vimcmd') return '' endif let cmd = readfile('vimcmd')[0] ! let cmd = substitute(cmd, '-u \f\+', '-u NONE', '') ! if cmd !~ '-u NONE' ! let cmd = cmd . ' -u NONE' endif let cmd .= ' --not-a-term' let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '') --- 166,186 ---- 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(...) 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 ' . name, '') ! if cmd !~ '-u '. name ! let cmd = cmd . ' -u ' . name endif let cmd .= ' --not-a-term' let cmd = substitute(cmd, 'VIMRUNTIME=.*VIMRUNTIME;', '', '') *** ../vim-8.0.1052/src/testdir/test_alot.vim 2017-09-02 19:45:00.049425409 +0200 --- src/testdir/test_alot.vim 2017-09-04 20:18:28.460640375 +0200 *************** *** 1,6 **** --- 1,8 ---- " 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 *** ../vim-8.0.1052/src/testdir/test_bufline.vim 2017-09-02 19:45:00.045425435 +0200 --- src/testdir/test_bufline.vim 2017-09-04 20:27:32.985105240 +0200 *************** *** 24,26 **** --- 24,39 ---- 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 *** ../vim-8.0.1052/src/testdir/test_timers.vim 2017-09-03 15:48:07.907554560 +0200 --- src/testdir/test_timers.vim 2017-09-04 20:29:53.492192490 +0200 *************** *** 1,7 **** " Test for timers - source shared.vim - if !has('timers') finish endif --- 1,5 ---- *** ../vim-8.0.1052/src/evalfunc.c 2017-09-03 15:48:07.907554560 +0200 --- src/evalfunc.c 2017-09-04 20:34:10.874520456 +0200 *************** *** 9885,9891 **** buf_T *curbuf_save; int is_curbuf = buf == curbuf; ! if (buf == NULL || buf->b_ml.ml_mfp == NULL || lnum < 1) { rettv->vval.v_number = 1; /* FAIL */ return; --- 9885,9894 ---- buf_T *curbuf_save; int is_curbuf = buf == curbuf; ! /* 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; *** ../vim-8.0.1052/src/version.c 2017-09-03 20:59:36.026190759 +0200 --- src/version.c 2017-09-04 20:32:43.119090775 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 1053, /**/ -- Q: How many legs does a giraffe have? A: Eight: two in front, two behind, two on the left and two on the right /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///