summaryrefslogtreecommitdiff
path: root/src/option.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-06-22 14:16:31 +0200
committerBram Moolenaar <Bram@vim.org>2017-06-22 14:16:31 +0200
commit9049298f8d0bbc237b7c666c7ad6cdabe738e8fc (patch)
treef5a3b4182582beb7047ec7be20f2b550f888976b /src/option.c
parentfadacf01d0dbcc7a96ef5eee0ad57956eeab04d7 (diff)
downloadvim-git-9049298f8d0bbc237b7c666c7ad6cdabe738e8fc.tar.gz
patch 8.0.0649: when opening a help file the filetype is set several timesv8.0.0649
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.
Diffstat (limited to 'src/option.c')
-rw-r--r--src/option.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/option.c b/src/option.c
index 2a92bc5ae..154c28b5a 100644
--- 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