To: vim_dev@googlegroups.com Subject: Patch 9.0.0391 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0391 Problem: Using separate delete() call instead of writefile() 'D' flag. Solution: Use the writefile 'D' flag. Files: src/testdir/test_backup.vim, src/testdir/test_balloon.vim, src/testdir/test_breakindent.vim, src/testdir/test_buffer.vim, src/testdir/test_bufline.vim *** ../vim-9.0.0390/src/testdir/test_backup.vim 2022-08-29 11:02:55.227279554 +0100 --- src/testdir/test_backup.vim 2022-09-05 21:27:10.079390405 +0100 *************** *** 78,88 **** " Test for using a non-existing directory as a backup directory func Test_non_existing_backupdir() set backupdir=./non_existing_dir backupskip= ! call writefile(['line1'], 'Xbackupdir') new Xbackupdir call assert_fails('write', 'E510:') set backupdir&vim backupskip&vim - call delete('Xbackupdir') endfunc " vim: shiftwidth=2 sts=2 expandtab --- 78,88 ---- " Test for using a non-existing directory as a backup directory func Test_non_existing_backupdir() set backupdir=./non_existing_dir backupskip= ! call writefile(['line1'], 'Xbackupdir', 'D') new Xbackupdir call assert_fails('write', 'E510:') + set backupdir&vim backupskip&vim endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.0390/src/testdir/test_balloon.vim 2022-01-22 15:06:08.000000000 +0000 --- src/testdir/test_balloon.vim 2022-09-05 21:28:48.639296571 +0100 *************** *** 29,35 **** call feedkeys("\\", "xt") endfunc [CODE] ! call writefile(s:common_script + xtra_lines, 'XTest_beval') " Check that the balloon shows up after a mouse move let buf = RunVimInTerminal('-S XTest_beval', {'rows': 10, 'cols': 50}) --- 29,35 ---- call feedkeys("\\", "xt") endfunc [CODE] ! call writefile(s:common_script + xtra_lines, 'XTest_beval', 'D') " Check that the balloon shows up after a mouse move let buf = RunVimInTerminal('-S XTest_beval', {'rows': 10, 'cols': 50}) *************** *** 45,51 **** " clean up call StopVimInTerminal(buf) - call delete('XTest_beval') endfunc func Test_balloon_eval_term_visual() --- 45,50 ---- *************** *** 54,60 **** call writefile(s:common_script + [ \ 'call test_setmouse(3, 6)', \ 'call feedkeys("3Gevfr\\", "xt")', ! \ ], 'XTest_beval_visual') " Check that the balloon shows up after a mouse move let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50}) --- 53,59 ---- call writefile(s:common_script + [ \ 'call test_setmouse(3, 6)', \ 'call feedkeys("3Gevfr\\", "xt")', ! \ ], 'XTest_beval_visual', 'D') " Check that the balloon shows up after a mouse move let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50}) *************** *** 63,69 **** " clean up call StopVimInTerminal(buf) - call delete('XTest_beval_visual') endfunc " vim: shiftwidth=2 sts=2 expandtab --- 62,67 ---- *** ../vim-9.0.0390/src/testdir/test_breakindent.vim 2022-09-02 14:08:50.217794529 +0100 --- src/testdir/test_breakindent.vim 2022-09-05 21:29:24.207258887 +0100 *************** *** 902,915 **** repeat('x', &columns - leftcol - 1)->setline(1) 'second line'->setline(2) END ! call writefile(lines, 'XscriptShowbreak') let buf = RunVimInTerminal('-S XscriptShowbreak', #{rows: 6}) call term_sendkeys(buf, "AX") call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak', {}) call StopVimInTerminal(buf) - call delete('XscriptShowbreak') endfunc func Test_no_spurious_match() --- 902,914 ---- repeat('x', &columns - leftcol - 1)->setline(1) 'second line'->setline(2) END ! call writefile(lines, 'XscriptShowbreak', 'D') let buf = RunVimInTerminal('-S XscriptShowbreak', #{rows: 6}) call term_sendkeys(buf, "AX") call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak', {}) call StopVimInTerminal(buf) endfunc func Test_no_spurious_match() *** ../vim-9.0.0390/src/testdir/test_buffer.vim 2022-08-30 21:46:03.657214444 +0100 --- src/testdir/test_buffer.vim 2022-09-05 21:32:51.487007312 +0100 *************** *** 5,68 **** " Test for the :bunload command with an offset func Test_bunload_with_offset() %bwipe! ! call writefile(['B1'], 'b1') ! call writefile(['B2'], 'b2') ! call writefile(['B3'], 'b3') ! call writefile(['B4'], 'b4') " Load four buffers. Unload the second and third buffers and then " execute .+3bunload to unload the last buffer. ! edit b1 ! new b2 ! new b3 ! new b4 ! ! bunload b2 ! bunload b3 ! exe bufwinnr('b1') . 'wincmd w' .+3bunload ! call assert_equal(0, getbufinfo('b4')[0].loaded) ! call assert_equal('b1', \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) " Load four buffers. Unload the third and fourth buffers. Execute .+3bunload " and check whether the second buffer is unloaded. ball ! bunload b3 ! bunload b4 ! exe bufwinnr('b1') . 'wincmd w' .+3bunload ! call assert_equal(0, getbufinfo('b2')[0].loaded) ! call assert_equal('b1', \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) " Load four buffers. Unload the second and third buffers and from the last " buffer execute .-3bunload to unload the first buffer. ball ! bunload b2 ! bunload b3 ! exe bufwinnr('b4') . 'wincmd w' .-3bunload ! call assert_equal(0, getbufinfo('b1')[0].loaded) ! call assert_equal('b4', \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) " Load four buffers. Unload the first and second buffers. Execute .-3bunload " from the last buffer and check whether the third buffer is unloaded. ball ! bunload b1 ! bunload b2 ! exe bufwinnr('b4') . 'wincmd w' .-3bunload ! call assert_equal(0, getbufinfo('b3')[0].loaded) ! call assert_equal('b4', \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) %bwipe! - call delete('b1') - call delete('b2') - call delete('b3') - call delete('b4') call assert_fails('1,4bunload', 'E16:') call assert_fails(',100bunload', 'E16:') --- 5,64 ---- " Test for the :bunload command with an offset func Test_bunload_with_offset() %bwipe! ! call writefile(['B1'], 'Xb1', 'D') ! call writefile(['B2'], 'Xb2', 'D') ! call writefile(['B3'], 'Xb3', 'D') ! call writefile(['B4'], 'Xb4', 'D') " Load four buffers. Unload the second and third buffers and then " execute .+3bunload to unload the last buffer. ! edit Xb1 ! new Xb2 ! new Xb3 ! new Xb4 ! ! bunload Xb2 ! bunload Xb3 ! exe bufwinnr('Xb1') . 'wincmd w' .+3bunload ! call assert_equal(0, getbufinfo('Xb4')[0].loaded) ! call assert_equal('Xb1', \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) " Load four buffers. Unload the third and fourth buffers. Execute .+3bunload " and check whether the second buffer is unloaded. ball ! bunload Xb3 ! bunload Xb4 ! exe bufwinnr('Xb1') . 'wincmd w' .+3bunload ! call assert_equal(0, getbufinfo('Xb2')[0].loaded) ! call assert_equal('Xb1', \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) " Load four buffers. Unload the second and third buffers and from the last " buffer execute .-3bunload to unload the first buffer. ball ! bunload Xb2 ! bunload Xb3 ! exe bufwinnr('Xb4') . 'wincmd w' .-3bunload ! call assert_equal(0, getbufinfo('Xb1')[0].loaded) ! call assert_equal('Xb4', \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) " Load four buffers. Unload the first and second buffers. Execute .-3bunload " from the last buffer and check whether the third buffer is unloaded. ball ! bunload Xb1 ! bunload Xb2 ! exe bufwinnr('Xb4') . 'wincmd w' .-3bunload ! call assert_equal(0, getbufinfo('Xb3')[0].loaded) ! call assert_equal('Xb4', \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) %bwipe! call assert_fails('1,4bunload', 'E16:') call assert_fails(',100bunload', 'E16:') *************** *** 76,84 **** %bwipe! call assert_fails('buffer 1000', 'E86:') ! call writefile(['foo1', 'foo2', 'foo3', 'foo4'], 'Xbrowse1') ! call writefile(['bar1', 'bar2', 'bar3', 'bar4'], 'Xbrowse2') ! call writefile(['baz1', 'baz2', 'baz3', 'baz4'], 'Xbrowse3') edit Xbrowse1 let b1 = bufnr() edit Xbrowse2 --- 72,80 ---- %bwipe! call assert_fails('buffer 1000', 'E86:') ! call writefile(['foo1', 'foo2', 'foo3', 'foo4'], 'Xbrowse1', 'D') ! call writefile(['bar1', 'bar2', 'bar3', 'bar4'], 'Xbrowse2', 'D') ! call writefile(['baz1', 'baz2', 'baz3', 'baz4'], 'Xbrowse3', 'D') edit Xbrowse1 let b1 = bufnr() edit Xbrowse2 *************** *** 127,135 **** call assert_fails('sandbox bnext', 'E48:') - call delete('Xbrowse1') - call delete('Xbrowse2') - call delete('Xbrowse3') %bwipe! endfunc --- 123,128 ---- *************** *** 200,212 **** " Test for quitting the 'swapfile exists' dialog with the split buffer " command. func Test_buffer_sbuf_cleanup() ! call writefile([], 'XsplitCleanup') " first open the file in a buffer new XsplitCleanup let bnr = bufnr() close " create the swap file ! call writefile([], '.XsplitCleanup.swp') " Remove the catch-all that runtest.vim adds au! SwapExists augroup BufTest --- 193,205 ---- " Test for quitting the 'swapfile exists' dialog with the split buffer " command. func Test_buffer_sbuf_cleanup() ! call writefile([], 'XsplitCleanup', 'D') " first open the file in a buffer new XsplitCleanup let bnr = bufnr() close " create the swap file ! call writefile([], '.XsplitCleanup.swp', 'D') " Remove the catch-all that runtest.vim adds au! SwapExists augroup BufTest *************** *** 231,238 **** call assert_equal(0, getbufinfo('XsplitCleanup')[0].loaded) set shortmess& - call delete('XsplitCleanup') - call delete('.XsplitCleanup.swp') augroup BufTest au! augroup END --- 224,229 ---- *************** *** 325,332 **** " Test for using CTRL-^ to edit the alternative file keeping the cursor " position with 'nostartofline'. Also test using the 'buf' command. func Test_buffer_edit_altfile() ! call writefile(repeat(['one two'], 50), 'Xaltfile1') ! call writefile(repeat(['five six'], 50), 'Xaltfile2') set nosol edit Xaltfile1 call cursor(25, 5) --- 316,323 ---- " Test for using CTRL-^ to edit the alternative file keeping the cursor " position with 'nostartofline'. Also test using the 'buf' command. func Test_buffer_edit_altfile() ! call writefile(repeat(['one two'], 50), 'Xaltfile1', 'D') ! call writefile(repeat(['five six'], 50), 'Xaltfile2', 'D') set nosol edit Xaltfile1 call cursor(25, 5) *************** *** 341,348 **** buf Xaltfile2 call assert_equal([0, 30, 4, 0], getpos('.')) set sol& - call delete('Xaltfile1') - call delete('Xaltfile2') endfunc " Test for running the :sball command with a maximum window count and a --- 332,337 ---- *************** *** 494,500 **** call assert_fails('%bw!', 'E342:') " test for :checktime loading the buffer ! call writefile(['one'], 'XallocFail5') if has('unix') edit XallocFail5 " sleep for some time to make sure the timestamp is different --- 483,489 ---- call assert_fails('%bw!', 'E342:') " test for :checktime loading the buffer ! call writefile(['one'], 'XallocFail5', 'D') if has('unix') edit XallocFail5 " sleep for some time to make sure the timestamp is different *************** *** 510,516 **** " test for :vimgrep loading a dummy buffer call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call assert_fails('vimgrep two XallocFail5', 'E342:') - call delete('XallocFail5') " test for quickfix command loading a buffer call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) --- 499,504 ---- *** ../vim-9.0.0390/src/testdir/test_bufline.vim 2022-08-26 15:34:48.244902157 +0100 --- src/testdir/test_bufline.vim 2022-09-05 21:38:04.922552818 +0100 *************** *** 81,91 **** if cmd == '' return endif ! call writefile(['call setline(1, "Hello")', 'silent w Xtest', 'q!'], 'Xscript') call system(cmd) call assert_equal(['Hello'], readfile('Xtest')) - call delete('Xscript') call delete('Xtest') endfunc --- 81,90 ---- if cmd == '' return endif ! call writefile(['call setline(1, "Hello")', 'silent w Xtest', 'q!'], 'Xscript', 'D') call system(cmd) call assert_equal(['Hello'], readfile('Xtest')) call delete('Xtest') endfunc *************** *** 214,225 **** call deletebufline(buf, 1, '$') call appendbufline(buf, '$', 'Hello Vim world...') END ! call writefile(lines, 'XscriptMatchCommon') let buf = RunVimInTerminal('-S XscriptMatchCommon', #{rows: 10}) call VerifyScreenDump(buf, 'Test_appendbufline_1', {}) call StopVimInTerminal(buf) - call delete('XscriptMatchCommon') endfunc func Test_setbufline_select_mode() --- 213,223 ---- call deletebufline(buf, 1, '$') call appendbufline(buf, '$', 'Hello Vim world...') END ! call writefile(lines, 'XscriptMatchCommon', 'D') let buf = RunVimInTerminal('-S XscriptMatchCommon', #{rows: 10}) call VerifyScreenDump(buf, 'Test_appendbufline_1', {}) call StopVimInTerminal(buf) endfunc func Test_setbufline_select_mode() *** ../vim-9.0.0390/src/version.c 2022-09-05 21:21:21.135941382 +0100 --- src/version.c 2022-09-05 21:40:03.906365108 +0100 *************** *** 705,706 **** --- 705,708 ---- { /* Add new patch number below this line */ + /**/ + 391, /**/ -- 10e12 microphone == 1 megaphone /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///