comparison src/option.c @ 14099:1157f16150b3 v8.1.0067

patch 8.1.0067: syntax highlighting not working when re-entering a buffer commit https://github.com/vim/vim/commit/a5616b0136cea2104a475d143a1685d71e9b2d3d Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 17 19:08:30 2018 +0200 patch 8.1.0067: syntax highlighting not working when re-entering a buffer Problem: Syntax highlighting not working when re-entering a buffer. Solution: Do force executing autocommands when not called recursively.
author Christian Brabandt <cb@256bit.org>
date Sun, 17 Jun 2018 19:15:05 +0200
parents db44cd9f8068
children 2ad722003b36
comparison
equal deleted inserted replaced
14098:d9ce494519f8 14099:1157f16150b3
7565 */ 7565 */
7566 #ifdef FEAT_SYN_HL 7566 #ifdef FEAT_SYN_HL
7567 /* When 'syntax' is set, load the syntax of that name */ 7567 /* When 'syntax' is set, load the syntax of that name */
7568 if (varp == &(curbuf->b_p_syn)) 7568 if (varp == &(curbuf->b_p_syn))
7569 { 7569 {
7570 // Only pass TRUE for "force" when the value changed, to avoid 7570 static int syn_recursive = 0;
7571 // endless recurrence. */ 7571
7572 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, 7572 ++syn_recursive;
7573 curbuf->b_fname, value_changed, curbuf); 7573 // Only pass TRUE for "force" when the value changed or not used
7574 // recursively, to avoid endless recurrence.
7575 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname,
7576 value_changed || syn_recursive == 1, curbuf);
7577 --syn_recursive;
7574 } 7578 }
7575 #endif 7579 #endif
7576 else if (varp == &(curbuf->b_p_ft)) 7580 else if (varp == &(curbuf->b_p_ft))
7577 { 7581 {
7578 /* 'filetype' is set, trigger the FileType autocommand. 7582 /* 'filetype' is set, trigger the FileType autocommand.
7579 * Skip this when called from a modeline and the filetype was 7583 * Skip this when called from a modeline and the filetype was
7580 * already set to this value. 7584 * already set to this value. */
7581 * Only pass TRUE for "force" when the value changed, to avoid
7582 * endless recurrence. */
7583 if (!(opt_flags & OPT_MODELINE) || value_changed) 7585 if (!(opt_flags & OPT_MODELINE) || value_changed)
7584 { 7586 {
7587 static int ft_recursive = 0;
7588
7589 ++ft_recursive;
7585 did_filetype = TRUE; 7590 did_filetype = TRUE;
7586 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, 7591 // Only pass TRUE for "force" when the value changed or not
7587 curbuf->b_fname, value_changed, curbuf); 7592 // used recursively, to avoid endless recurrence.
7593 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, curbuf->b_fname,
7594 value_changed || ft_recursive == 1, curbuf);
7595 --ft_recursive;
7588 /* Just in case the old "curbuf" is now invalid. */ 7596 /* Just in case the old "curbuf" is now invalid. */
7589 if (varp != &(curbuf->b_p_ft)) 7597 if (varp != &(curbuf->b_p_ft))
7590 varp = NULL; 7598 varp = NULL;
7591 } 7599 }
7592 } 7600 }