diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-09-30 02:53:18 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-09-30 02:58:34 -0400 |
commit | 9dcd5bd9c5272e28f7f52f579b74381e46ce827d (patch) | |
tree | 12d8c060ba3d23e5470bd4cbb8a7ecea1ff4f938 /src/nvim/option.c | |
parent | 6a680548ec3e81e9d228cb8ac9e4380368068387 (diff) | |
download | rneovim-9dcd5bd9c5272e28f7f52f579b74381e46ce827d.tar.gz rneovim-9dcd5bd9c5272e28f7f52f579b74381e46ce827d.tar.bz2 rneovim-9dcd5bd9c5272e28f7f52f579b74381e46ce827d.zip |
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.
https://github.com/vim/vim/commit/a5616b0136cea2104a475d143a1685d71e9b2d3d
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r-- | src/nvim/option.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 1440180e4b..eb2780ce7a 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3237,20 +3237,28 @@ 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--; } 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. 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; |