From c7f1e4002184903f4e12e429dd5c6ab731932f86 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 3 Aug 2019 13:29:46 +0200 Subject: patch 8.1.1795: no syntax HL after splitting windows with :bufdo Problem: No syntax HL after splitting windows with :bufdo. (Yasuhiro Matsumoto) Solution: Trigger Syntax autocommands in buffers that are active. (closes #4761) --- src/ex_cmds2.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/ex_cmds2.c') 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 -- cgit v1.2.3