mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch-8.0.0649 and vim-patch-8.0.0650: autocmd open help 2 times
This commit is contained in:
parent
09b51bbf87
commit
e9134421ab
@ -1,7 +1,7 @@
|
|||||||
" Vim support file to detect file types
|
" Vim support file to detect file types
|
||||||
"
|
"
|
||||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
" Last Change: 2017 Nov 02
|
" Last Change: 2018 Feb 14
|
||||||
|
|
||||||
" Listen very carefully, I will say this only once
|
" Listen very carefully, I will say this only once
|
||||||
if exists("did_load_filetypes")
|
if exists("did_load_filetypes")
|
||||||
@ -48,6 +48,9 @@ func! s:StarSetf(ft)
|
|||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Vim help file
|
||||||
|
au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt setf help
|
||||||
|
|
||||||
" Abaqus or Trasys
|
" Abaqus or Trasys
|
||||||
au BufNewFile,BufRead *.inp call s:Check_inp()
|
au BufNewFile,BufRead *.inp call s:Check_inp()
|
||||||
|
|
||||||
@ -2804,8 +2807,13 @@ au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh')
|
|||||||
|
|
||||||
" Plain text files, needs to be far down to not override others. This avoids
|
" Plain text files, needs to be far down to not override others. This avoids
|
||||||
" the "conf" type being used if there is a line starting with '#'.
|
" the "conf" type being used if there is a line starting with '#'.
|
||||||
au BufNewFile,BufRead *.txt,*.text,README setf text
|
au BufNewFile,BufRead *.text,README setf text
|
||||||
|
|
||||||
|
" Help files match *.txt but should have a last line that is a modeline.
|
||||||
|
au BufNewFile,BufRead *.txt
|
||||||
|
\ if getline('$') !~ 'vim:.*ft=help'
|
||||||
|
\| setf text
|
||||||
|
\| endif
|
||||||
|
|
||||||
" Use the filetype detect plugins. They may overrule any of the previously
|
" Use the filetype detect plugins. They may overrule any of the previously
|
||||||
" detected filetypes.
|
" detected filetypes.
|
||||||
|
@ -4864,7 +4864,9 @@ void fix_help_buffer(void)
|
|||||||
char_u *rt;
|
char_u *rt;
|
||||||
|
|
||||||
// Set filetype to "help".
|
// Set filetype to "help".
|
||||||
set_option_value("ft", 0L, "help", OPT_LOCAL);
|
if (STRCMP(curbuf->b_p_ft, "help") != 0) {
|
||||||
|
set_option_value("ft", 0L, "help", OPT_LOCAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (!syntax_present(curwin)) {
|
if (!syntax_present(curwin)) {
|
||||||
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) {
|
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) {
|
||||||
|
@ -2455,6 +2455,7 @@ did_set_string_option (
|
|||||||
int did_chartab = FALSE;
|
int did_chartab = FALSE;
|
||||||
char_u **gvarp;
|
char_u **gvarp;
|
||||||
bool free_oldval = (options[opt_idx].flags & P_ALLOCED);
|
bool free_oldval = (options[opt_idx].flags & P_ALLOCED);
|
||||||
|
int ft_changed = false;
|
||||||
|
|
||||||
/* Get the global option to compare with, otherwise we would have to check
|
/* Get the global option to compare with, otherwise we would have to check
|
||||||
* two values for all local options. */
|
* two values for all local options. */
|
||||||
@ -3174,6 +3175,8 @@ did_set_string_option (
|
|||||||
} else if (gvarp == &p_ft) {
|
} else if (gvarp == &p_ft) {
|
||||||
if (!valid_filetype(*varp)) {
|
if (!valid_filetype(*varp)) {
|
||||||
errmsg = e_invarg;
|
errmsg = e_invarg;
|
||||||
|
} else {
|
||||||
|
ft_changed = STRCMP(oldval, *varp) != 0;
|
||||||
}
|
}
|
||||||
} else if (gvarp == &p_syn) {
|
} else if (gvarp == &p_syn) {
|
||||||
if (!valid_filetype(*varp)) {
|
if (!valid_filetype(*varp)) {
|
||||||
@ -3256,10 +3259,12 @@ did_set_string_option (
|
|||||||
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 if (varp == &(curbuf->b_p_ft)) {
|
} else if (varp == &(curbuf->b_p_ft)) {
|
||||||
/* 'filetype' is set, trigger the FileType autocommand */
|
// 'filetype' is set, trigger the FileType autocommand
|
||||||
did_filetype = TRUE;
|
if (!(opt_flags & OPT_MODELINE) || ft_changed) {
|
||||||
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
|
did_filetype = true;
|
||||||
curbuf->b_fname, TRUE, curbuf);
|
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
|
||||||
|
curbuf->b_fname, true, curbuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (varp == &(curwin->w_s->b_p_spl)) {
|
if (varp == &(curwin->w_s->b_p_spl)) {
|
||||||
char_u fname[200];
|
char_u fname[200];
|
||||||
|
16
test/functional/autocmd/filetype_spec.lua
Normal file
16
test/functional/autocmd/filetype_spec.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
|
||||||
|
local eval = helpers.eval
|
||||||
|
local clear = helpers.clear
|
||||||
|
local command = helpers.command
|
||||||
|
|
||||||
|
describe('autocmd FileType', function()
|
||||||
|
before_each(clear)
|
||||||
|
|
||||||
|
it("is triggered by :help only once", function()
|
||||||
|
command("let g:foo = 0")
|
||||||
|
command("autocmd FileType help let g:foo = g:foo + 1")
|
||||||
|
command("help help")
|
||||||
|
assert.same(1, eval('g:foo'))
|
||||||
|
end)
|
||||||
|
end)
|
Loading…
Reference in New Issue
Block a user