From 42c922b32c0a22fbe078d03bac5de0cfa7bd0b9f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 12 Jan 2017 02:33:15 +0100 Subject: open_buffer(): Do `BufEnter` for directories. Abuse NOTDONE to give some nuance to the return value of readfile(), so that open_buffer() can distinguish between "failed, lol" and "failed because the path is a directory". Before this change, Vim *already* creates a new buffer when a directory is edited. So there is no reason it should not raise BufEnter, that was an implementation detail of ye olde readfile(). Most of the changes in this commit merely preserve the old semantics. The "implicit" change that we actually are interested in, is this line in `open_buffer()`, where `retval` being non-FAIL allows EVENT_BUFENTER to be applied: apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf, &retval); References https://github.com/vim/vim/issues/1353 --- src/nvim/buffer.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/nvim/buffer.c') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index d9fdc80c60..5ab96ca67d 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -193,10 +193,13 @@ open_buffer ( * it can be changed there. */ if (!readonlymode && !bufempty()) changed(); - else if (retval != FAIL) + else if (retval == OK) { unchanged(curbuf, FALSE); - apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE, - curbuf, &retval); + } + if (retval == OK) { + apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE, + curbuf, &retval); + } } } @@ -219,7 +222,7 @@ open_buffer ( || (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL) ) changed(); - else if (retval != FAIL && !read_stdin) + else if (retval == OK && !read_stdin) unchanged(curbuf, FALSE); save_file_ff(curbuf); /* keep this fileformat */ -- cgit