aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fileio.c
diff options
context:
space:
mode:
authorJurica Bradarić <jbradaric@users.noreply.github.com>2016-09-04 23:43:41 +0200
committerJustin M. Keyes <justinkz@gmail.com>2016-09-04 23:43:41 +0200
commit73b8424fad108d1ae5981f7fad32f12df35fef2e (patch)
treeadc84aa82a17afe6464064ab11e2fa5b1170c62c /src/nvim/fileio.c
parent0f381f26cbbe7f50de106c996d8a9d946db61574 (diff)
downloadrneovim-73b8424fad108d1ae5981f7fad32f12df35fef2e.tar.gz
rneovim-73b8424fad108d1ae5981f7fad32f12df35fef2e.tar.bz2
rneovim-73b8424fad108d1ae5981f7fad32f12df35fef2e.zip
vim-patch:7.4.1913 (#5260)
Problem: When ":doautocmd" is used modelines are used even when no autocommands were executed. (Daniel Hahler) Solution: Skip processing modelines. (closes vim/vim#854) https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r--src/nvim/fileio.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index e0b6ae1215..89e5fdb776 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -3773,8 +3773,9 @@ static int set_rw_fname(char_u *fname, char_u *sfname)
/* Do filetype detection now if 'filetype' is empty. */
if (*curbuf->b_p_ft == NUL) {
- if (au_has_group((char_u *)"filetypedetect"))
- (void)do_doautocmd((char_u *)"filetypedetect BufRead", FALSE);
+ if (au_has_group((char_u *)"filetypedetect")) {
+ (void)do_doautocmd((char_u *)"filetypedetect BufRead", false, NULL);
+ }
do_modelines(0);
}
@@ -6058,13 +6059,18 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd,
int
do_doautocmd (
char_u *arg,
- int do_msg /* give message for no matching autocmds? */
+ int do_msg, // give message for no matching autocmds?
+ bool *did_something
)
{
char_u *fname;
int nothing_done = TRUE;
int group;
+ if (did_something != NULL) {
+ *did_something = false;
+ }
+
/*
* Check for a legal group name. If not, use AUGROUP_ALL.
*/
@@ -6093,8 +6099,12 @@ do_doautocmd (
fname, NULL, TRUE, group, curbuf, NULL))
nothing_done = FALSE;
- if (nothing_done && do_msg)
+ if (nothing_done && do_msg) {
MSG(_("No matching autocommands"));
+ }
+ if (did_something != NULL) {
+ *did_something = !nothing_done;
+ }
return aborting() ? FAIL : OK;
}
@@ -6123,13 +6133,14 @@ void ex_doautoall(exarg_T *eap)
/* find a window for this buffer and save some values */
aucmd_prepbuf(&aco, buf);
- /* execute the autocommands for this buffer */
- retval = do_doautocmd(arg, FALSE);
+ bool did_aucmd;
+ // execute the autocommands for this buffer
+ retval = do_doautocmd(arg, false, &did_aucmd);
- if (call_do_modelines) {
- /* Execute the modeline settings, but don't set window-local
- * options if we are using the current window for another
- * buffer. */
+ if (call_do_modelines && did_aucmd) {
+ // Execute the modeline settings, but don't set window-local
+ // options if we are using the current window for another
+ // buffer.
do_modelines(curwin == aucmd_win ? OPT_NOWIN : 0);
}