forked from aniani/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 #4761)
This commit is contained in:
@@ -1447,9 +1447,15 @@ ex_listdo(exarg_T *eap)
|
|||||||
|
|
||||||
#if defined(FEAT_SYN_HL)
|
#if defined(FEAT_SYN_HL)
|
||||||
if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo)
|
if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo)
|
||||||
|
{
|
||||||
/* Don't do syntax HL autocommands. Skipping the syntax file is a
|
/* Don't do syntax HL autocommands. Skipping the syntax file is a
|
||||||
* great speed improvement. */
|
* great speed improvement. */
|
||||||
save_ei = au_event_disable(",Syntax");
|
save_ei = au_event_disable(",Syntax");
|
||||||
|
|
||||||
|
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
||||||
|
buf->b_flags &= ~BF_SYN_SET;
|
||||||
|
buf = curbuf;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_CLIPBOARD
|
#ifdef FEAT_CLIPBOARD
|
||||||
start_global_changes();
|
start_global_changes();
|
||||||
@@ -1641,9 +1647,35 @@ ex_listdo(exarg_T *eap)
|
|||||||
#if defined(FEAT_SYN_HL)
|
#if defined(FEAT_SYN_HL)
|
||||||
if (save_ei != NULL)
|
if (save_ei != NULL)
|
||||||
{
|
{
|
||||||
|
buf_T *bnext;
|
||||||
|
aco_save_T aco;
|
||||||
|
|
||||||
au_event_restore(save_ei);
|
au_event_restore(save_ei);
|
||||||
|
|
||||||
|
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,
|
apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
|
||||||
curbuf->b_fname, TRUE, curbuf);
|
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
|
#endif
|
||||||
#ifdef FEAT_CLIPBOARD
|
#ifdef FEAT_CLIPBOARD
|
||||||
|
@@ -7931,6 +7931,7 @@ did_set_string_option(
|
|||||||
// recursively, to avoid endless recurrence.
|
// recursively, to avoid endless recurrence.
|
||||||
apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname,
|
apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname,
|
||||||
value_changed || syn_recursive == 1, curbuf);
|
value_changed || syn_recursive == 1, curbuf);
|
||||||
|
curbuf->b_flags |= BF_SYN_SET;
|
||||||
--syn_recursive;
|
--syn_recursive;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -582,3 +582,41 @@ func Test_syn_wrong_z_one()
|
|||||||
call test_override("ALL", 0)
|
call test_override("ALL", 0)
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_syntax_after_bufdo()
|
||||||
|
call writefile(['/* aaa comment */'], 'Xaaa.c')
|
||||||
|
call writefile(['/* bbb comment */'], 'Xbbb.c')
|
||||||
|
call writefile(['/* ccc comment */'], 'Xccc.c')
|
||||||
|
call writefile(['/* ddd comment */'], 'Xddd.c')
|
||||||
|
|
||||||
|
let bnr = bufnr('%')
|
||||||
|
new Xaaa.c
|
||||||
|
badd Xbbb.c
|
||||||
|
badd Xccc.c
|
||||||
|
badd Xddd.c
|
||||||
|
exe "bwipe " . bnr
|
||||||
|
let l = []
|
||||||
|
bufdo call add(l, bufnr('%'))
|
||||||
|
call assert_equal(4, len(l))
|
||||||
|
|
||||||
|
syntax on
|
||||||
|
|
||||||
|
" This used to only enable syntax HL in the last buffer.
|
||||||
|
bufdo tab split
|
||||||
|
tabrewind
|
||||||
|
for tab in range(1, 4)
|
||||||
|
norm fm
|
||||||
|
call assert_equal(['cComment'], map(synstack(line("."), col(".")), 'synIDattr(v:val, "name")'))
|
||||||
|
tabnext
|
||||||
|
endfor
|
||||||
|
|
||||||
|
bwipe! Xaaa.c
|
||||||
|
bwipe! Xbbb.c
|
||||||
|
bwipe! Xccc.c
|
||||||
|
bwipe! Xddd.c
|
||||||
|
syntax off
|
||||||
|
call delete('Xaaa.c')
|
||||||
|
call delete('Xbbb.c')
|
||||||
|
call delete('Xccc.c')
|
||||||
|
call delete('Xddd.c')
|
||||||
|
endfunc
|
||||||
|
@@ -773,6 +773,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1795,
|
||||||
/**/
|
/**/
|
||||||
1794,
|
1794,
|
||||||
/**/
|
/**/
|
||||||
|
29
src/vim.h
29
src/vim.h
@@ -698,20 +698,21 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
|
|||||||
#define NOTDONE 2 /* not OK or FAIL but skipped */
|
#define NOTDONE 2 /* not OK or FAIL but skipped */
|
||||||
|
|
||||||
/* flags for b_flags */
|
/* flags for b_flags */
|
||||||
#define BF_RECOVERED 0x01 /* buffer has been recovered */
|
#define BF_RECOVERED 0x01 // buffer has been recovered
|
||||||
#define BF_CHECK_RO 0x02 /* need to check readonly when loading file
|
#define BF_CHECK_RO 0x02 // need to check readonly when loading file
|
||||||
into buffer (set by ":e", may be reset by
|
// into buffer (set by ":e", may be reset by
|
||||||
":buf" */
|
// ":buf"
|
||||||
#define BF_NEVERLOADED 0x04 /* file has never been loaded into buffer,
|
#define BF_NEVERLOADED 0x04 // file has never been loaded into buffer,
|
||||||
many variables still need to be set */
|
// many variables still need to be set
|
||||||
#define BF_NOTEDITED 0x08 /* Set when file name is changed after
|
#define BF_NOTEDITED 0x08 // Set when file name is changed after
|
||||||
starting to edit, reset when file is
|
// starting to edit, reset when file is
|
||||||
written out. */
|
// written out.
|
||||||
#define BF_NEW 0x10 /* file didn't exist when editing started */
|
#define BF_NEW 0x10 // file didn't exist when editing started
|
||||||
#define BF_NEW_W 0x20 /* Warned for BF_NEW and file created */
|
#define BF_NEW_W 0x20 // Warned for BF_NEW and file created
|
||||||
#define BF_READERR 0x40 /* got errors while reading the file */
|
#define BF_READERR 0x40 // got errors while reading the file
|
||||||
#define BF_DUMMY 0x80 /* dummy buffer, only used internally */
|
#define BF_DUMMY 0x80 // dummy buffer, only used internally
|
||||||
#define BF_PRESERVED 0x100 /* ":preserve" was used */
|
#define BF_PRESERVED 0x100 // ":preserve" was used
|
||||||
|
#define BF_SYN_SET 0x200 // 'syntax' option was set
|
||||||
|
|
||||||
/* Mask to check for flags that prevent normal writing */
|
/* Mask to check for flags that prevent normal writing */
|
||||||
#define BF_WRITE_MASK (BF_NOTEDITED + BF_NEW + BF_READERR)
|
#define BF_WRITE_MASK (BF_NOTEDITED + BF_NEW + BF_READERR)
|
||||||
|
Reference in New Issue
Block a user