fix(filetype): avoid recursive FileType autocmds (#22813)

This commit is contained in:
Lewis Russell
2023-03-29 19:54:12 +01:00
committed by GitHub
parent 92005db760
commit 8b7fb668e4
3 changed files with 42 additions and 36 deletions

View File

@@ -111,15 +111,15 @@ static buf_T *do_ft_buf(char *filetype, aco_save_T *aco, Error *err)
// Set curwin/curbuf to buf and save a few things.
aucmd_prepbuf(aco, ftbuf);
set_option_value("bufhidden", 0L, "hide", OPT_LOCAL);
set_option_value("buftype", 0L, "nofile", OPT_LOCAL);
set_option_value("swapfile", 0L, NULL, OPT_LOCAL);
set_option_value("modeline", 0L, NULL, OPT_LOCAL); // 'nomodeline'
ftbuf->b_p_ft = xstrdup(filetype);
TRY_WRAP(err, {
apply_autocmds(EVENT_FILETYPE, ftbuf->b_p_ft, ftbuf->b_fname, true, ftbuf);
set_option_value("bufhidden", 0L, "hide", OPT_LOCAL);
set_option_value("buftype", 0L, "nofile", OPT_LOCAL);
set_option_value("swapfile", 0L, NULL, OPT_LOCAL);
set_option_value("modeline", 0L, NULL, OPT_LOCAL); // 'nomodeline'
ftbuf->b_p_ft = xstrdup(filetype);
do_filetype_autocmd(ftbuf, false);
});
return ftbuf;