diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/nvim/ex_cmds.c | 4 | ||||
| -rw-r--r-- | src/nvim/option.c | 13 | 
2 files changed, 12 insertions, 5 deletions
| diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 2873f76ce0..48d1d42e2e 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4864,7 +4864,9 @@ void fix_help_buffer(void)    char_u      *rt;    // Set filetype to "help". -  set_option_value("ft", 0L, "help", OPT_LOCAL); +  if (STRCMP(curbuf->b_p_ft, "help") != 0) { +    set_option_value("ft", 0L, "help", OPT_LOCAL); +  }    if (!syntax_present(curwin)) {      for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) { diff --git a/src/nvim/option.c b/src/nvim/option.c index c805e41ec5..2341371f65 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2455,6 +2455,7 @@ did_set_string_option (    int did_chartab = FALSE;    char_u      **gvarp;    bool free_oldval = (options[opt_idx].flags & P_ALLOCED); +  int ft_changed = false;    /* Get the global option to compare with, otherwise we would have to check     * two values for all local options. */ @@ -3174,6 +3175,8 @@ did_set_string_option (    } else if (gvarp == &p_ft) {      if (!valid_filetype(*varp)) {        errmsg = e_invarg; +    } else { +      ft_changed = STRCMP(oldval, *varp) != 0;      }    } else if (gvarp == &p_syn) {      if (!valid_filetype(*varp)) { @@ -3256,10 +3259,12 @@ did_set_string_option (        apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,            curbuf->b_fname, TRUE, curbuf);      } 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, -          curbuf->b_fname, TRUE, curbuf); +      // 'filetype' is set, trigger the FileType autocommand +      if (!(opt_flags & OPT_MODELINE) || ft_changed) { +        did_filetype = true; +        apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, +                       curbuf->b_fname, true, curbuf); +      }      }      if (varp == &(curwin->w_s->b_p_spl)) {        char_u fname[200]; | 
