]> granicus.if.org Git - vim/commitdiff
patch 9.0.0275: BufEnter not triggered when using ":edit" in "nofile" buffer v9.0.0275
authorBram Moolenaar <Bram@vim.org>
Fri, 26 Aug 2022 12:16:20 +0000 (13:16 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 26 Aug 2022 12:16:20 +0000 (13:16 +0100)
Problem:    BufEnter not triggered when using ":edit" in "nofile" buffer.
Solution:   Let readfile() return NOTDONE. (closes #10986)

src/fileio.c
src/testdir/test_autocmd.vim
src/version.c

index 1b30e0fed52b2a248b5fa3b2ffef3be5f4de5b91..8437b2b44742bade194a03485170b2c332efaf76 100644 (file)
@@ -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)
index c043a3531145470120037663db9d3cf59d2b55a0..4b0928517a734b93527eb4defc9937b0bf95c5d3 100644 (file)
@@ -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
index 959097468596604e94343e551086e6c30d0ab464..e32f990bcb797f6140b695a7c67165c3bf0ae5bb 100644 (file)
@@ -723,6 +723,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    275,
 /**/
     274,
 /**/