Mercurial > vim
comparison src/buffer.c @ 10575:01a5f64a7a20 v8.0.0177
patch 8.0.0177: BufEnter autocommand not fired for a directory
commit https://github.com/vim/vim/commit/e13b9afe1283f5ae43232b5992372a0eb570666c
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jan 13 22:01:02 2017 +0100
patch 8.0.0177: BufEnter autocommand not fired for a directory
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 13 Jan 2017 22:15:03 +0100 |
parents | 262f5bc3d38e |
children | c647f01d6dbd |
comparison
equal
deleted
inserted
replaced
10574:7eaa92b1da91 | 10575:01a5f64a7a20 |
---|---|
111 { | 111 { |
112 /* Set or reset 'modified' before executing autocommands, so that | 112 /* Set or reset 'modified' before executing autocommands, so that |
113 * it can be changed there. */ | 113 * it can be changed there. */ |
114 if (!readonlymode && !bufempty()) | 114 if (!readonlymode && !bufempty()) |
115 changed(); | 115 changed(); |
116 else if (retval != FAIL) | 116 else if (retval == OK) |
117 unchanged(curbuf, FALSE); | 117 unchanged(curbuf, FALSE); |
118 | 118 |
119 #ifdef FEAT_AUTOCMD | 119 #ifdef FEAT_AUTOCMD |
120 if (retval == OK) | |
121 { | |
120 # ifdef FEAT_EVAL | 122 # ifdef FEAT_EVAL |
121 apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE, | 123 apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE, |
122 curbuf, &retval); | 124 curbuf, &retval); |
123 # else | 125 # else |
124 apply_autocmds(EVENT_STDINREADPOST, NULL, NULL, FALSE, curbuf); | 126 apply_autocmds(EVENT_STDINREADPOST, NULL, NULL, FALSE, curbuf); |
125 # endif | 127 # endif |
128 } | |
126 #endif | 129 #endif |
127 } | 130 } |
128 return retval; | 131 return retval; |
129 } | 132 } |
130 | 133 |
292 || (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL) | 295 || (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL) |
293 # endif | 296 # endif |
294 #endif | 297 #endif |
295 ) | 298 ) |
296 changed(); | 299 changed(); |
297 else if (retval != FAIL && !read_stdin && !read_fifo) | 300 else if (retval == OK && !read_stdin && !read_fifo) |
298 unchanged(curbuf, FALSE); | 301 unchanged(curbuf, FALSE); |
299 save_file_ff(curbuf); /* keep this fileformat */ | 302 save_file_ff(curbuf); /* keep this fileformat */ |
300 | 303 |
301 /* require "!" to overwrite the file, because it wasn't read completely */ | 304 /* require "!" to overwrite the file, because it wasn't read completely */ |
302 #ifdef FEAT_EVAL | 305 #ifdef FEAT_EVAL |
326 # else | 329 # else |
327 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | 330 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); |
328 # endif | 331 # endif |
329 #endif | 332 #endif |
330 | 333 |
331 if (retval != FAIL) | 334 if (retval == OK) |
332 { | 335 { |
333 #ifdef FEAT_AUTOCMD | 336 #ifdef FEAT_AUTOCMD |
334 /* | 337 /* |
335 * The autocommands may have changed the current buffer. Apply the | 338 * The autocommands may have changed the current buffer. Apply the |
336 * modelines to the correct buffer, if it still exists and is loaded. | 339 * modelines to the correct buffer, if it still exists and is loaded. |