Skip to content

Commit a5616b0

Browse files
committed
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.
1 parent c3ffc9b commit a5616b0

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

src/option.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7567,24 +7567,32 @@ did_set_string_option(
75677567
/* When 'syntax' is set, load the syntax of that name */
75687568
if (varp == &(curbuf->b_p_syn))
75697569
{
7570-
// Only pass TRUE for "force" when the value changed, to avoid
7571-
// endless recurrence. */
7572-
apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7573-
curbuf->b_fname, value_changed, curbuf);
7570+
static int syn_recursive = 0;
7571+
7572+
++syn_recursive;
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;
75747578
}
75757579
#endif
75767580
else if (varp == &(curbuf->b_p_ft))
75777581
{
75787582
/* 'filetype' is set, trigger the FileType autocommand.
75797583
* Skip this when called from a modeline and the filetype was
7580-
* already set to this value.
7581-
* Only pass TRUE for "force" when the value changed, to avoid
7582-
* endless recurrence. */
7584+
* already set to this value. */
75837585
if (!(opt_flags & OPT_MODELINE) || value_changed)
75847586
{
7587+
static int ft_recursive = 0;
7588+
7589+
++ft_recursive;
75857590
did_filetype = TRUE;
7586-
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7587-
curbuf->b_fname, value_changed, curbuf);
7591+
// Only pass TRUE for "force" when the value changed or not
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;
75887596
/* Just in case the old "curbuf" is now invalid. */
75897597
if (varp != &(curbuf->b_p_ft))
75907598
varp = NULL;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
67,
764766
/**/
765767
66,
766768
/**/

0 commit comments

Comments
 (0)