mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 08:18:17 +00:00
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)
1610d05241
This commit is contained in:

committed by
Justin M. Keyes

parent
0f381f26cb
commit
73b8424fad
@@ -1711,11 +1711,11 @@ int do_write(exarg_T *eap)
|
|||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If 'filetype' was empty try detecting it now. */
|
// If 'filetype' was empty try detecting it now.
|
||||||
if (*curbuf->b_p_ft == NUL) {
|
if (*curbuf->b_p_ft == NUL) {
|
||||||
if (au_has_group((char_u *)"filetypedetect"))
|
if (au_has_group((char_u *)"filetypedetect")) {
|
||||||
(void)do_doautocmd((char_u *)"filetypedetect BufRead",
|
(void)do_doautocmd((char_u *)"filetypedetect BufRead", true, NULL);
|
||||||
TRUE);
|
}
|
||||||
do_modelines(0);
|
do_modelines(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4366,11 +4366,14 @@ static void ex_doautocmd(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
char_u *arg = eap->arg;
|
char_u *arg = eap->arg;
|
||||||
int call_do_modelines = check_nomodeline(&arg);
|
int call_do_modelines = check_nomodeline(&arg);
|
||||||
|
bool did_aucmd;
|
||||||
|
|
||||||
(void)do_doautocmd(arg, TRUE);
|
(void)do_doautocmd(arg, true, &did_aucmd);
|
||||||
if (call_do_modelines) /* Only when there is no <nomodeline>. */
|
// Only when there is no <nomodeline>.
|
||||||
|
if (call_do_modelines && did_aucmd) {
|
||||||
do_modelines(0);
|
do_modelines(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* :[N]bunload[!] [N] [bufname] unload buffer
|
* :[N]bunload[!] [N] [bufname] unload buffer
|
||||||
@@ -9464,7 +9467,7 @@ static void ex_filetype(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*arg == 'd') {
|
if (*arg == 'd') {
|
||||||
(void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE);
|
(void)do_doautocmd((char_u *)"filetypedetect BufRead", true, NULL);
|
||||||
do_modelines(0);
|
do_modelines(0);
|
||||||
}
|
}
|
||||||
} else if (STRCMP(arg, "off") == 0) {
|
} else if (STRCMP(arg, "off") == 0) {
|
||||||
|
@@ -3773,8 +3773,9 @@ static int set_rw_fname(char_u *fname, char_u *sfname)
|
|||||||
|
|
||||||
/* Do filetype detection now if 'filetype' is empty. */
|
/* Do filetype detection now if 'filetype' is empty. */
|
||||||
if (*curbuf->b_p_ft == NUL) {
|
if (*curbuf->b_p_ft == NUL) {
|
||||||
if (au_has_group((char_u *)"filetypedetect"))
|
if (au_has_group((char_u *)"filetypedetect")) {
|
||||||
(void)do_doautocmd((char_u *)"filetypedetect BufRead", FALSE);
|
(void)do_doautocmd((char_u *)"filetypedetect BufRead", false, NULL);
|
||||||
|
}
|
||||||
do_modelines(0);
|
do_modelines(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6058,13 +6059,18 @@ static int do_autocmd_event(event_T event, char_u *pat, int nested, char_u *cmd,
|
|||||||
int
|
int
|
||||||
do_doautocmd (
|
do_doautocmd (
|
||||||
char_u *arg,
|
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;
|
char_u *fname;
|
||||||
int nothing_done = TRUE;
|
int nothing_done = TRUE;
|
||||||
int group;
|
int group;
|
||||||
|
|
||||||
|
if (did_something != NULL) {
|
||||||
|
*did_something = false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for a legal group name. If not, use AUGROUP_ALL.
|
* Check for a legal group name. If not, use AUGROUP_ALL.
|
||||||
*/
|
*/
|
||||||
@@ -6093,8 +6099,12 @@ do_doautocmd (
|
|||||||
fname, NULL, TRUE, group, curbuf, NULL))
|
fname, NULL, TRUE, group, curbuf, NULL))
|
||||||
nothing_done = FALSE;
|
nothing_done = FALSE;
|
||||||
|
|
||||||
if (nothing_done && do_msg)
|
if (nothing_done && do_msg) {
|
||||||
MSG(_("No matching autocommands"));
|
MSG(_("No matching autocommands"));
|
||||||
|
}
|
||||||
|
if (did_something != NULL) {
|
||||||
|
*did_something = !nothing_done;
|
||||||
|
}
|
||||||
|
|
||||||
return aborting() ? FAIL : OK;
|
return aborting() ? FAIL : OK;
|
||||||
}
|
}
|
||||||
@@ -6123,13 +6133,14 @@ void ex_doautoall(exarg_T *eap)
|
|||||||
/* find a window for this buffer and save some values */
|
/* find a window for this buffer and save some values */
|
||||||
aucmd_prepbuf(&aco, buf);
|
aucmd_prepbuf(&aco, buf);
|
||||||
|
|
||||||
/* execute the autocommands for this buffer */
|
bool did_aucmd;
|
||||||
retval = do_doautocmd(arg, FALSE);
|
// execute the autocommands for this buffer
|
||||||
|
retval = do_doautocmd(arg, false, &did_aucmd);
|
||||||
|
|
||||||
if (call_do_modelines) {
|
if (call_do_modelines && did_aucmd) {
|
||||||
/* Execute the modeline settings, but don't set window-local
|
// Execute the modeline settings, but don't set window-local
|
||||||
* options if we are using the current window for another
|
// options if we are using the current window for another
|
||||||
* buffer. */
|
// buffer.
|
||||||
do_modelines(curwin == aucmd_win ? OPT_NOWIN : 0);
|
do_modelines(curwin == aucmd_win ? OPT_NOWIN : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -363,7 +363,7 @@ static int included_patches[] = {
|
|||||||
// 1916 NA
|
// 1916 NA
|
||||||
// 1915 NA
|
// 1915 NA
|
||||||
// 1914,
|
// 1914,
|
||||||
// 1913,
|
1913,
|
||||||
// 1912,
|
// 1912,
|
||||||
// 1911,
|
// 1911,
|
||||||
// 1910,
|
// 1910,
|
||||||
|
Reference in New Issue
Block a user