# HG changeset patch # User Christian Brabandt # Date 1498134603 -7200 # Node ID c83dd5fa40d87cdfa97dc5e7292f77f8fe6ab3f6 # Parent fbc166ba3f00ec6b4c7ca553232fe0daa9485897 patch 8.0.0649: when opening a help file the filetype is set several times commit https://github.com/vim/vim/commit/9049298f8d0bbc237b7c666c7ad6cdabe738e8fc Author: Bram Moolenaar Date: Thu Jun 22 14:16:31 2017 +0200 patch 8.0.0649: when opening a help file the filetype is set several times Problem: When opening a help file the filetype is set several times. Solution: When setting the filetype to the same value from a modeline, don't trigger FileType autocommands. Don't set the filetype to "help" when it's already set correctly. diff --git a/runtime/filetype.vim b/runtime/filetype.vim --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar -" Last Change: 2017 Jun 12 +" Last Change: 2017 Jun 20 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -48,6 +48,9 @@ func! s:StarSetf(ft) endif endfunc +" Vim help file +au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt setf help + " Abaqus or Trasys au BufNewFile,BufRead *.inp call s:Check_inp() diff --git a/src/ex_cmds.c b/src/ex_cmds.c --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -6832,8 +6832,9 @@ fix_help_buffer(void) char_u *rt; int mustfree; - /* set filetype to "help". */ - set_option_value((char_u *)"ft", 0L, (char_u *)"help", OPT_LOCAL); + /* Set filetype to "help" if still needed. */ + if (STRCMP(curbuf->b_p_ft, "help") != 0) + set_option_value((char_u *)"ft", 0L, (char_u *)"help", OPT_LOCAL); #ifdef FEAT_SYN_HL if (!syntax_present(curwin)) diff --git a/src/option.c b/src/option.c --- a/src/option.c +++ b/src/option.c @@ -6009,6 +6009,9 @@ did_set_string_option( /* set when changing an option that only requires a redraw in the GUI */ int redraw_gui_only = FALSE; #endif +#ifdef FEAT_AUTOCMD + int ft_changed = FALSE; +#endif /* Get the global option to compare with, otherwise we would have to check * two values for all local options. */ @@ -7418,6 +7421,8 @@ did_set_string_option( { if (!valid_filetype(*varp)) errmsg = e_invarg; + else + ft_changed = STRCMP(oldval, *varp) != 0; } #endif @@ -7531,10 +7536,15 @@ did_set_string_option( # endif else if (varp == &(curbuf->b_p_ft)) { - /* 'filetype' is set, trigger the FileType autocommand */ - did_filetype = TRUE; - apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, + /* 'filetype' is set, trigger the FileType autocommand. + * Skip this when called from a modeline and the filetype was + * already set to this value. */ + if (!(opt_flags & OPT_MODELINE) || ft_changed) + { + did_filetype = TRUE; + apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, curbuf->b_fname, TRUE, curbuf); + } } #endif #ifdef FEAT_SPELL diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 649, +/**/ 648, /**/ 647,