summaryrefslogtreecommitdiff
path: root/src/option.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-06-17 19:08:30 +0200
committerBram Moolenaar <Bram@vim.org>2018-06-17 19:08:30 +0200
commita5616b0136cea2104a475d143a1685d71e9b2d3d (patch)
tree66cb35fb5573134bc5ecc895f22a1864e90d632c /src/option.c
parentc3ffc9b8d3015dc5280b297b4e3deb4f34944bd4 (diff)
downloadvim-git-a5616b0136cea2104a475d143a1685d71e9b2d3d.tar.gz
patch 8.1.0067: syntax highlighting not working when re-entering a bufferv8.1.0067
Problem: Syntax highlighting not working when re-entering a buffer. Solution: Do force executing autocommands when not called recursively.
Diffstat (limited to 'src/option.c')
-rw-r--r--src/option.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/option.c b/src/option.c
index 2ecdcea64..cf774ac23 100644
--- a/src/option.c
+++ b/src/option.c
@@ -7567,24 +7567,32 @@ did_set_string_option(
/* When 'syntax' is set, load the syntax of that name */
if (varp == &(curbuf->b_p_syn))
{
- // Only pass TRUE for "force" when the value changed, to avoid
- // endless recurrence. */
- apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
- curbuf->b_fname, value_changed, 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;
}
#endif
else if (varp == &(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.
- * Only pass TRUE for "force" when the value changed, to avoid
- * endless recurrence. */
+ * 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, value_changed, 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;