aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-01-13 04:09:37 +0100
committerGitHub <noreply@github.com>2017-01-13 04:09:37 +0100
commitf68663542037aaa4ae954aacae7adf2e88b151d5 (patch)
tree4e007995ce7eed3937d8aeb791cf25f0f5ea1e19 /src/nvim/buffer.c
parent802b49ee803aed63c15bd35ffc10e1ba2ba30e59 (diff)
parent82edcb593b19755187371635d7b5aabdf024bd1f (diff)
downloadrneovim-f68663542037aaa4ae954aacae7adf2e88b151d5.tar.gz
rneovim-f68663542037aaa4ae954aacae7adf2e88b151d5.tar.bz2
rneovim-f68663542037aaa4ae954aacae7adf2e88b151d5.zip
Merge #5933 from justinmk/dir-bufenter
open_buffer(): Raise `BufEnter` for directories.
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index d9fdc80c60..04a3235dc6 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -189,14 +189,18 @@ open_buffer (
curwin->w_cursor.lnum = 1;
curwin->w_cursor.col = 0;
- /* Set or reset 'modified' before executing autocommands, so that
- * it can be changed there. */
- if (!readonlymode && !bufempty())
+ // Set or reset 'modified' before executing autocommands, so that
+ // it can be changed there.
+ if (!readonlymode && !bufempty()) {
changed();
- else if (retval != FAIL)
- unchanged(curbuf, FALSE);
- apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE,
- curbuf, &retval);
+ } else if (retval == OK) {
+ unchanged(curbuf, false);
+ }
+
+ if (retval == OK) {
+ apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, false,
+ curbuf, &retval);
+ }
}
}
@@ -206,22 +210,21 @@ open_buffer (
parse_cino(curbuf);
}
- /*
- * Set/reset the Changed flag first, autocmds may change the buffer.
- * Apply the automatic commands, before processing the modelines.
- * So the modelines have priority over auto commands.
- */
- /* When reading stdin, the buffer contents always needs writing, so set
- * the changed flag. Unless in readonly mode: "ls | nvim -R -".
- * When interrupted and 'cpoptions' contains 'i' set changed flag. */
+ // Set/reset the Changed flag first, autocmds may change the buffer.
+ // Apply the automatic commands, before processing the modelines.
+ // So the modelines have priority over auto commands.
+
+ // When reading stdin, the buffer contents always needs writing, so set
+ // the changed flag. Unless in readonly mode: "ls | nvim -R -".
+ // When interrupted and 'cpoptions' contains 'i' set changed flag.
if ((got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
- || modified_was_set /* ":set modified" used in autocmd */
- || (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
- )
+ || modified_was_set // ":set modified" used in autocmd
+ || (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL)) {
changed();
- else if (retval != FAIL && !read_stdin)
- unchanged(curbuf, FALSE);
- save_file_ff(curbuf); /* keep this fileformat */
+ } else if (retval == OK && !read_stdin) {
+ unchanged(curbuf, false);
+ }
+ save_file_ff(curbuf); // keep this fileformat
/* require "!" to overwrite the file, because it wasn't read completely */
if (aborting())