Mercurial > vim
diff src/ex_cmds2.c @ 17596:892b4ea3bad6 v8.1.1795
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
commit https://github.com/vim/vim/commit/c7f1e4002184903f4e12e429dd5c6ab731932f86
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 3 13:29:46 2019 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 03 Aug 2019 13:30:07 +0200 |
parents | 8f44c630c366 |
children | ff097edaae89 |
line wrap: on
line diff
--- 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