diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-10-17 12:34:25 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-10-17 13:48:52 -0400 |
commit | 242af4dc991f12474eb281eb64236922b423cdbe (patch) | |
tree | 54fb8384808b80ed9ec095414fa61b2f3c6cee18 /src/nvim/ex_cmds2.c | |
parent | e1ec2b0729d54710b6fbdf17e02d030468dbed15 (diff) | |
download | rneovim-242af4dc991f12474eb281eb64236922b423cdbe.tar.gz rneovim-242af4dc991f12474eb281eb64236922b423cdbe.tar.bz2 rneovim-242af4dc991f12474eb281eb64236922b423cdbe.zip |
vim-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 vim/vim#4761)
https://github.com/vim/vim/commit/c7f1e4002184903f4e12e429dd5c6ab731932f86
Diffstat (limited to 'src/nvim/ex_cmds2.c')
-rw-r--r-- | src/nvim/ex_cmds2.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 3e169f7a4e..503fd8e0d0 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2058,6 +2058,10 @@ void ex_listdo(exarg_T *eap) // Don't do syntax HL autocommands. Skipping the syntax file is a // great speed improvement. save_ei = au_event_disable(",Syntax"); + + FOR_ALL_BUFFERS(buf) { + buf->b_flags &= ~BF_SYN_SET; + } } if (eap->cmdidx == CMD_windo @@ -2252,9 +2256,32 @@ void ex_listdo(exarg_T *eap) } if (save_ei != NULL) { + buf_T *bnext; + aco_save_T aco; + au_event_restore(save_ei); - apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, - curbuf->b_fname, true, curbuf); + + for (buf_T *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; + } + } } } |