diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-26 20:18:02 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-08-27 06:12:52 +0800 |
commit | 45c23a757c6fc601a76a92f052f55eb3ed469364 (patch) | |
tree | 4e19c885a0103b1232685f735c666f49e3909b43 | |
parent | 52f00a6c4d84a13a85ff265a5c59c92795d1b333 (diff) | |
download | rneovim-45c23a757c6fc601a76a92f052f55eb3ed469364.tar.gz rneovim-45c23a757c6fc601a76a92f052f55eb3ed469364.tar.bz2 rneovim-45c23a757c6fc601a76a92f052f55eb3ed469364.zip |
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)
https://github.com/vim/vim/commit/a9b5b85068b2fcb1c01ea20524e227bcad579ceb
-rw-r--r-- | src/nvim/fileio.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_autocmd.vim | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index fdba186200..0b66878103 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -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 } } diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index f21b958f1a..778e5f9b9f 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -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 |