aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-09-30 14:48:29 +0200
committerGitHub <noreply@github.com>2018-09-30 14:48:29 +0200
commitc6d36b97bac0df86c1120af323db1b577dc90629 (patch)
tree12d8c060ba3d23e5470bd4cbb8a7ecea1ff4f938 /src/nvim/option.c
parent6e146d413267de044a1f9f0bbb0290b5387e631c (diff)
parent9dcd5bd9c5272e28f7f52f579b74381e46ce827d (diff)
downloadrneovim-c6d36b97bac0df86c1120af323db1b577dc90629.tar.gz
rneovim-c6d36b97bac0df86c1120af323db1b577dc90629.tar.bz2
rneovim-c6d36b97bac0df86c1120af323db1b577dc90629.zip
Merge #9067 from janlazo/vim-8.0.1485
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r--src/nvim/option.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index b4ee89d128..eb2780ce7a 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -2434,7 +2434,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;
+ bool value_changed = false;
/* Get the global option to compare with, otherwise we would have to check
* two values for all local options. */
@@ -3155,11 +3155,13 @@ did_set_string_option (
if (!valid_filetype(*varp)) {
errmsg = e_invarg;
} else {
- ft_changed = STRCMP(oldval, *varp) != 0;
+ value_changed = STRCMP(oldval, *varp) != 0;
}
} else if (gvarp == &p_syn) {
if (!valid_filetype(*varp)) {
errmsg = e_invarg;
+ } else {
+ value_changed = STRCMP(oldval, *varp) != 0;
}
} else if (varp == &curwin->w_p_winhl) {
if (!parse_winhl_opt(curwin)) {
@@ -3235,14 +3237,28 @@ did_set_string_option (
*/
/* When 'syntax' is set, load the syntax of that name */
if (varp == &(curbuf->b_p_syn)) {
- apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
- curbuf->b_fname, TRUE, curbuf);
+ static int syn_recursive = 0;
+
+ syn_recursive++;
+ // Only pass true for "force" when the value changed or not used
+ // recursively, to avoid endless recurrence.
+ apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname,
+ value_changed || syn_recursive == 1, curbuf);
+ syn_recursive--;
} else if (varp == &(curbuf->b_p_ft)) {
// 'filetype' is set, trigger the FileType autocommand
- if (!(opt_flags & OPT_MODELINE) || ft_changed) {
+ // Skip this when called from a modeline and the filetype was
+ // already set to this value.
+ if (!(opt_flags & OPT_MODELINE) || value_changed) {
+ static int ft_recursive = 0;
+
+ ft_recursive++;
did_filetype = true;
- apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
- curbuf->b_fname, true, curbuf);
+ // Only pass true for "force" when the value changed or not
+ // used recursively, to avoid endless recurrence.
+ apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, curbuf->b_fname,
+ value_changed || ft_recursive == 1, curbuf);
+ ft_recursive--;
// Just in case the old "curbuf" is now invalid
if (varp != &(curbuf->b_p_ft)) {
varp = NULL;