To: vim_dev@googlegroups.com Subject: Patch 9.0.0332 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0332 Problem: Overwrite check may block BufWriteCmd. Solution: Do not use overwrite check when 'buftype' is "acwrite". (closes #11011) Files: src/ex_cmds.c, src/testdir/test_autocmd.vim *** ../vim-9.0.0331/src/ex_cmds.c 2022-08-29 15:06:46.716715543 +0100 --- src/ex_cmds.c 2022-08-30 18:12:44.579390272 +0100 *************** *** 2094,2105 **** /* * Write to another file or b_flags set or not writing the whole file: * overwriting only allowed with '!'. */ if ( (other ! || (buf->b_flags & BF_NOTEDITED) ! || ((buf->b_flags & BF_NEW) ! && vim_strchr(p_cpo, CPO_OVERNEW) == NULL) ! || (buf->b_flags & BF_READERR)) && !p_wa && vim_fexists(ffname)) { --- 2094,2110 ---- /* * Write to another file or b_flags set or not writing the whole file: * overwriting only allowed with '!'. + * If "other" is FALSE and bt_nofilename(buf) is TRUE, this must be + * writing an "acwrite" buffer to the same file as its b_ffname, and + * buf_write() will only allow writing with BufWriteCmd autocommands, + * so there is no need for an overwrite check. */ if ( (other ! || (!bt_nofilename(buf) ! && ((buf->b_flags & BF_NOTEDITED) ! || ((buf->b_flags & BF_NEW) ! && vim_strchr(p_cpo, CPO_OVERNEW) == NULL) ! || (buf->b_flags & BF_READERR)))) && !p_wa && vim_fexists(ffname)) { *** ../vim-9.0.0331/src/testdir/test_autocmd.vim 2022-08-29 22:31:15.919685279 +0100 --- src/testdir/test_autocmd.vim 2022-08-30 18:12:44.579390272 +0100 *************** *** 1922,1927 **** --- 1922,1942 ---- au! BufWriteCmd endfunc + func Test_BufWriteCmd() + autocmd BufWriteCmd Xbufwritecmd let g:written = 1 + new + file Xbufwritecmd + set buftype=acwrite + call mkdir('Xbufwritecmd') + write + " BufWriteCmd should be triggered even if a directory has the same name + call assert_equal(1, g:written) + call delete('Xbufwritecmd', 'd') + unlet g:written + au! BufWriteCmd + bwipe! + endfunc + func SetChangeMarks(start, end) exe a:start .. 'mark [' exe a:end .. 'mark ]' *** ../vim-9.0.0331/src/version.c 2022-08-30 17:45:28.787606578 +0100 --- src/version.c 2022-08-30 18:16:59.398054520 +0100 *************** *** 709,710 **** --- 709,712 ---- { /* Add new patch number below this line */ + /**/ + 332, /**/ -- If you don't get everything you want, think of everything you didn't get and don't want. /// 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 ///