diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-08-03 13:29:46 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-08-03 13:29:46 +0200 |
commit | c7f1e4002184903f4e12e429dd5c6ab731932f86 (patch) | |
tree | a101834cbba39badc74d3882e2f011218848c3bf /src/ex_cmds2.c | |
parent | f2d8b7a0a69fd71018341755da5ce55d067b5923 (diff) |
patch 8.1.1795: no syntax HL after splitting windows with :bufdov8.1.1795
Problem: No syntax HL after splitting windows with :bufdo. (Yasuhiro
Matsumoto)
Solution: Trigger Syntax autocommands in buffers that are active.
(closes #4761)
Diffstat (limited to 'src/ex_cmds2.c')
-rw-r--r-- | src/ex_cmds2.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index a275fb8b70..a8be96dc32 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1447,9 +1447,15 @@ ex_listdo(exarg_T *eap) #if defined(FEAT_SYN_HL) if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo) + { /* Don't do syntax HL autocommands. Skipping the syntax file is a * great speed improvement. */ save_ei = au_event_disable(",Syntax"); + + for (buf = firstbuf; buf != NULL; buf = buf->b_next) + buf->b_flags &= ~BF_SYN_SET; + buf = curbuf; + } #endif #ifdef FEAT_CLIPBOARD start_global_changes(); @@ -1641,9 +1647,35 @@ ex_listdo(exarg_T *eap) #if defined(FEAT_SYN_HL) if (save_ei != NULL) { + buf_T *bnext; + aco_save_T aco; + au_event_restore(save_ei); - apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, + + for (buf = firstbuf; buf != NULL; buf = bnext) + { + bnext = buf->b_next; + if (buf->b_nwindows > 0 && (buf->b_flags & BF_SYN_SET)) + { + buf->b_flags &= ~BF_SYN_SET; + + // buffer was opened while Syntax autocommands were disabled, + // need to trigger them now. + if (buf == curbuf) + apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname, TRUE, curbuf); + else + { + aucmd_prepbuf(&aco, buf); + apply_autocmds(EVENT_SYNTAX, buf->b_p_syn, + buf->b_fname, TRUE, buf); + aucmd_restbuf(&aco); + } + + // start over, in case autocommands messed things up. + bnext = firstbuf; + } + } } #endif #ifdef FEAT_CLIPBOARD |