1
0
forked from aniani/vim

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.
This commit is contained in:
Bram Moolenaar 2018-06-17 19:08:30 +02:00
parent c3ffc9b8d3
commit a5616b0136
2 changed files with 19 additions and 9 deletions

View File

@ -7567,24 +7567,32 @@ did_set_string_option(
/* When 'syntax' is set, load the syntax of that name */ /* When 'syntax' is set, load the syntax of that name */
if (varp == &(curbuf->b_p_syn)) if (varp == &(curbuf->b_p_syn))
{ {
// Only pass TRUE for "force" when the value changed, to avoid static int syn_recursive = 0;
// endless recurrence. */
apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, ++syn_recursive;
curbuf->b_fname, value_changed, curbuf); // 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;
} }
#endif #endif
else if (varp == &(curbuf->b_p_ft)) else if (varp == &(curbuf->b_p_ft))
{ {
/* 'filetype' is set, trigger the FileType autocommand. /* 'filetype' is set, trigger the FileType autocommand.
* Skip this when called from a modeline and the filetype was * Skip this when called from a modeline and the filetype was
* already set to this value. * already set to this value. */
* Only pass TRUE for "force" when the value changed, to avoid
* endless recurrence. */
if (!(opt_flags & OPT_MODELINE) || value_changed) if (!(opt_flags & OPT_MODELINE) || value_changed)
{ {
static int ft_recursive = 0;
++ft_recursive;
did_filetype = TRUE; did_filetype = TRUE;
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, // Only pass TRUE for "force" when the value changed or not
curbuf->b_fname, value_changed, curbuf); // 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. */ /* Just in case the old "curbuf" is now invalid. */
if (varp != &(curbuf->b_p_ft)) if (varp != &(curbuf->b_p_ft))
varp = NULL; varp = NULL;

View File

@ -761,6 +761,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
67,
/**/ /**/
66, 66,
/**/ /**/