mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
commit
4a2d2248e8
@ -187,6 +187,14 @@ struct bw_info {
|
|||||||
static char *e_auchangedbuf = N_(
|
static char *e_auchangedbuf = N_(
|
||||||
"E812: Autocommands changed buffer or buffer name");
|
"E812: Autocommands changed buffer or buffer name");
|
||||||
|
|
||||||
|
// Set by the apply_autocmds_group function if the given event is equal to
|
||||||
|
// EVENT_FILETYPE. Used by the readfile function in order to determine if
|
||||||
|
// EVENT_BUFREADPOST triggered the EVENT_FILETYPE.
|
||||||
|
//
|
||||||
|
// Relying on this value requires one to reset it prior calling
|
||||||
|
// apply_autocmds_group.
|
||||||
|
static bool au_did_filetype INIT(= false);
|
||||||
|
|
||||||
void filemess(buf_T *buf, char_u *name, char_u *s, int attr)
|
void filemess(buf_T *buf, char_u *name, char_u *s, int attr)
|
||||||
{
|
{
|
||||||
int msg_scroll_save;
|
int msg_scroll_save;
|
||||||
@ -329,6 +337,8 @@ readfile (
|
|||||||
int using_b_ffname;
|
int using_b_ffname;
|
||||||
int using_b_fname;
|
int using_b_fname;
|
||||||
|
|
||||||
|
au_did_filetype = false; // reset before triggering any autocommands
|
||||||
|
|
||||||
curbuf->b_no_eol_lnum = 0; /* in case it was set by the previous read */
|
curbuf->b_no_eol_lnum = 0; /* in case it was set by the previous read */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1957,20 +1967,29 @@ failed:
|
|||||||
* should not be overwritten: Set msg_scroll, restore its value if no
|
* should not be overwritten: Set msg_scroll, restore its value if no
|
||||||
* output was done.
|
* output was done.
|
||||||
*/
|
*/
|
||||||
msg_scroll = TRUE;
|
msg_scroll = true;
|
||||||
if (filtering)
|
if (filtering) {
|
||||||
apply_autocmds_exarg(EVENT_FILTERREADPOST, NULL, sfname,
|
apply_autocmds_exarg(EVENT_FILTERREADPOST, NULL, sfname,
|
||||||
FALSE, curbuf, eap);
|
false, curbuf, eap);
|
||||||
else if (newfile)
|
} else if (newfile) {
|
||||||
apply_autocmds_exarg(EVENT_BUFREADPOST, NULL, sfname,
|
apply_autocmds_exarg(EVENT_BUFREADPOST, NULL, sfname,
|
||||||
FALSE, curbuf, eap);
|
false, curbuf, eap);
|
||||||
else
|
if (!au_did_filetype && *curbuf->b_p_ft != NUL) {
|
||||||
|
// EVENT_FILETYPE was not triggered but the buffer already has a
|
||||||
|
// filetype. Trigger EVENT_FILETYPE using the existing filetype.
|
||||||
|
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, curbuf->b_fname,
|
||||||
|
true, curbuf);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
apply_autocmds_exarg(EVENT_FILEREADPOST, sfname, sfname,
|
apply_autocmds_exarg(EVENT_FILEREADPOST, sfname, sfname,
|
||||||
FALSE, NULL, eap);
|
false, NULL, eap);
|
||||||
if (msg_scrolled == n)
|
}
|
||||||
|
if (msg_scrolled == n) {
|
||||||
msg_scroll = m;
|
msg_scroll = m;
|
||||||
if (aborting()) /* autocmds may abort script processing */
|
}
|
||||||
|
if (aborting()) { // autocmds may abort script processing
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recoverymode && error)
|
if (recoverymode && error)
|
||||||
@ -6865,6 +6884,10 @@ BYPASS_AU:
|
|||||||
if (event == EVENT_BUFWIPEOUT && buf != NULL)
|
if (event == EVENT_BUFWIPEOUT && buf != NULL)
|
||||||
aubuflocal_remove(buf);
|
aubuflocal_remove(buf);
|
||||||
|
|
||||||
|
if (retval == OK && event == EVENT_FILETYPE) {
|
||||||
|
au_did_filetype = true;
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,3 +61,18 @@ func Test_syn_iskeyword()
|
|||||||
|
|
||||||
quit!
|
quit!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_syntax_after_reload()
|
||||||
|
split Xsomefile
|
||||||
|
call setline(1, ['hello', 'there'])
|
||||||
|
w!
|
||||||
|
only!
|
||||||
|
setl filetype=hello
|
||||||
|
au FileType hello let g:gotit = 1
|
||||||
|
call assert_false(exists('g:gotit'))
|
||||||
|
edit other
|
||||||
|
buf Xsomefile
|
||||||
|
call assert_equal('hello', &filetype)
|
||||||
|
call assert_true(exists('g:gotit'))
|
||||||
|
call delete('Xsomefile')
|
||||||
|
endfunc
|
||||||
|
@ -689,7 +689,7 @@ static int included_patches[] = {
|
|||||||
1757,
|
1757,
|
||||||
// 1756 NA
|
// 1756 NA
|
||||||
1755,
|
1755,
|
||||||
// 1754,
|
1754,
|
||||||
1753,
|
1753,
|
||||||
// 1753,
|
// 1753,
|
||||||
// 1752,
|
// 1752,
|
||||||
|
Loading…
Reference in New Issue
Block a user