summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-01-13 22:01:02 +0100
committerBram Moolenaar <Bram@vim.org>2017-01-13 22:01:02 +0100
commite13b9afe1283f5ae43232b5992372a0eb570666c (patch)
treebd533d936ffe99f5791dc6f2f9284d980a88633d /src/fileio.c
parent70bcd7336f9f19304f32c52a86ed5b4b3de852c2 (diff)
downloadvim-git-e13b9afe1283f5ae43232b5992372a0eb570666c.tar.gz
patch 8.0.0177: BufEnter autocommand not fired for a directoryv8.0.0177
Problem: When opening a buffer on a directory and inside a try/catch then the BufEnter event is not triggered. Solution: Return NOTDONE from readfile() for a directory and deal with the three possible return values. (Justin M. Keyes, closes #1375, closes #1353)
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/fileio.c b/src/fileio.c
index bcb8fef8b..aeb53b593 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -210,7 +210,7 @@ filemess(
* READ_KEEP_UNDO don't clear undo info or read it from a file
* READ_FIFO read from fifo/socket instead of a file
*
- * return FAIL for failure, OK otherwise
+ * return FAIL for failure, NOTDONE for directory (failure), or OK
*/
int
readfile(
@@ -450,13 +450,18 @@ readfile(
# endif
)
{
+ int retval = FAIL;
+
if (S_ISDIR(perm))
+ {
filemess(curbuf, fname, (char_u *)_("is a directory"), 0);
+ retval = NOTDONE;
+ }
else
filemess(curbuf, fname, (char_u *)_("is not a file"), 0);
msg_end();
msg_scroll = msg_save;
- return FAIL;
+ return retval;
}
#endif
#if defined(MSWIN)
@@ -7136,7 +7141,7 @@ buf_reload(buf_T *buf, int orig_mode)
#endif
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 defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
if (!aborting())