mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 09:18:19 +00:00
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
This commit is contained in:
@@ -249,7 +249,7 @@ void filemess(buf_T *buf, char_u *name, char_u *s, int attr)
|
||||
* READ_DUMMY read into a dummy buffer (to check if file contents changed)
|
||||
* READ_KEEP_UNDO don't clear undo info or read it from a file
|
||||
*
|
||||
* return FAIL for failure, OK otherwise
|
||||
* return FAIL for failure, NOTDONE for directory (failure), or OK
|
||||
*/
|
||||
int
|
||||
readfile (
|
||||
@@ -258,7 +258,7 @@ readfile (
|
||||
linenr_T from,
|
||||
linenr_T lines_to_skip,
|
||||
linenr_T lines_to_read,
|
||||
exarg_T *eap, /* can be NULL! */
|
||||
exarg_T *eap, // can be NULL!
|
||||
int flags
|
||||
)
|
||||
{
|
||||
@@ -444,13 +444,14 @@ readfile (
|
||||
// ... or a character special file named /dev/fd/<n>
|
||||
# endif
|
||||
) {
|
||||
if (S_ISDIR(perm))
|
||||
if (S_ISDIR(perm)) {
|
||||
filemess(curbuf, fname, (char_u *)_("is a directory"), 0);
|
||||
else
|
||||
} else {
|
||||
filemess(curbuf, fname, (char_u *)_("is not a file"), 0);
|
||||
}
|
||||
msg_end();
|
||||
msg_scroll = msg_save;
|
||||
return FAIL;
|
||||
return S_ISDIR(perm) ? NOTDONE : FAIL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -5108,7 +5109,7 @@ void buf_reload(buf_T *buf, int orig_mode)
|
||||
keep_filetype = TRUE; /* don't detect 'filetype' */
|
||||
if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0,
|
||||
(linenr_T)0,
|
||||
(linenr_T)MAXLNUM, &ea, flags) == FAIL) {
|
||||
(linenr_T)MAXLNUM, &ea, flags) != OK) {
|
||||
if (!aborting())
|
||||
EMSG2(_("E321: Could not reload \"%s\""), buf->b_fname);
|
||||
if (savebuf != NULL && buf_valid(savebuf) && buf == curbuf) {
|
||||
|
Reference in New Issue
Block a user