Mercurial > vim
changeset 29873:adc2dec6d27d v9.0.0275
patch 9.0.0275: BufEnter not triggered when using ":edit" in "nofile" buffer
Commit: https://github.com/vim/vim/commit/a9b5b85068b2fcb1c01ea20524e227bcad579ceb
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 26 13:16:20 2022 +0100
patch 9.0.0275: BufEnter not triggered when using ":edit" in "nofile" buffer
Problem: BufEnter not triggered when using ":edit" in "nofile" buffer.
Solution: Let readfile() return NOTDONE. (closes https://github.com/vim/vim/issues/10986)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 26 Aug 2022 14:30:03 +0200 |
parents | 01211e2b3df2 |
children | fd1e8bf02d4b |
files | src/fileio.c src/testdir/test_autocmd.vim src/version.c |
diffstat | 3 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fileio.c +++ b/src/fileio.c @@ -312,7 +312,7 @@ readfile( curbuf->b_op_start = orig_start; if (flags & READ_NOFILE) - return FAIL; + return NOTDONE; // so that BufEnter can be triggered } if ((shortmess(SHM_OVER) || curbuf->b_help) && p_verbose == 0)
--- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -681,9 +681,19 @@ func Test_BufEnter() " On MS-Windows we can't edit the directory, make sure we wipe the right " buffer. bwipe! Xdir - call delete('Xdir', 'd') au! BufEnter + + " Editing a "nofile" buffer doesn't read the file but does trigger BufEnter + " for historic reasons. + new somefile + set buftype=nofile + au BufEnter somefile call setline(1, 'some text') + edit + call assert_equal('some text', getline(1)) + + bwipe! + au! BufEnter endfunc " Closing a window might cause an endless loop