vim-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 vim/vim#10986)
a9b5b85068
This commit is contained in:
zeertzjq
2022-08-26 20:18:02 +08:00
parent 52f00a6c4d
commit 45c23a757c
2 changed files with 12 additions and 2 deletions

View File

@@ -337,7 +337,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
curbuf->b_op_start = orig_start;
if (flags & READ_NOFILE) {
return FAIL;
return NOTDONE; // so that BufEnter can be triggered
}
}

View File

@@ -599,9 +599,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