Patch 8.0.0677
Problem: Setting 'filetype' internally may cause the current buffer and
window to change unexpectedly.
Solution: Set curbuf_lock. (closes #1734)
Files: src/quickfix.c, src/ex_cmds.c, src/ex_getln.c,
src/testdir/test_quickfix.vim
*** ../vim-8.0.0676/src/quickfix.c 2017-06-22 21:29:17.205398557 +0200
--- src/quickfix.c 2017-06-25 21:00:17.419518007 +0200
***************
*** 3425,3430 ****
--- 3425,3433 ----
/* Set the 'filetype' to "qf" each time after filling the buffer.
* This resembles reading a file into a buffer, it's more logical when
* using autocommands. */
+ #ifdef FEAT_AUTOCMD
+ ++curbuf_lock;
+ #endif
set_option_value((char_u *)"ft", 0L, (char_u *)"qf", OPT_LOCAL);
curbuf->b_p_ma = FALSE;
***************
*** 3435,3440 ****
--- 3438,3444 ----
apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL,
FALSE, curbuf);
keep_filetype = FALSE;
+ --curbuf_lock;
#endif
/* make sure it will be redrawn */
redraw_curbuf_later(NOT_VALID);
*** ../vim-8.0.0676/src/ex_cmds.c 2017-06-22 14:54:53.018623545 +0200
--- src/ex_cmds.c 2017-06-25 21:01:31.974933602 +0200
***************
*** 6835,6841 ****
--- 6835,6845 ----
#ifdef FEAT_AUTOCMD
/* Set filetype to "help" if still needed. */
if (STRCMP(curbuf->b_p_ft, "help") != 0)
+ {
+ ++curbuf_lock;
set_option_value((char_u *)"ft", 0L, (char_u *)"help", OPT_LOCAL);
+ --curbuf_lock;
+ }
#endif
#ifdef FEAT_SYN_HL
*** ../vim-8.0.0676/src/ex_getln.c 2017-06-17 18:44:17.006000891 +0200
--- src/ex_getln.c 2017-06-25 21:03:32.893988659 +0200
***************
*** 6878,6883 ****
--- 6878,6885 ----
# ifdef FEAT_AUTOCMD
/* Do execute autocommands for setting the filetype (load syntax). */
unblock_autocmds();
+ /* But don't allow switching to another buffer. */
+ ++curbuf_lock;
# endif
/* Showing the prompt may have set need_wait_return, reset it. */
***************
*** 6893,6898 ****
--- 6895,6903 ----
}
set_option_value((char_u *)"ft", 0L, (char_u *)"vim", OPT_LOCAL);
}
+ # ifdef FEAT_AUTOCMD
+ --curbuf_lock;
+ # endif
/* Reset 'textwidth' after setting 'filetype' (the Vim filetype plugin
* sets 'textwidth' to 78). */
*** ../vim-8.0.0676/src/testdir/test_quickfix.vim 2017-06-22
21:29:17.209398525 +0200
--- src/testdir/test_quickfix.vim 2017-06-25 21:12:20.529864596 +0200
***************
*** 2190,2196 ****
func Test_cclose_from_copen()
augroup QF_Test
au!
! au FileType qf :cclose
augroup END
copen
augroup QF_Test
--- 2190,2196 ----
func Test_cclose_from_copen()
augroup QF_Test
au!
! au FileType qf :call assert_fails(':cclose', 'E788')
augroup END
copen
augroup QF_Test
***************
*** 2227,2229 ****
--- 2227,2245 ----
call XsizeTests('c')
call XsizeTests('l')
endfunc
+
+ func Test_cclose_in_autocmd()
+ " Problem is only triggered if "starting" is zero, so that the OptionsSet
+ " event will be triggered.
+ call test_override('starting', 1)
+ augroup QF_Test
+ au!
+ au FileType qf :call assert_fails(':cclose', 'E788')
+ augroup END
+ copen
+ augroup QF_Test
+ au!
+ augroup END
+ augroup! QF_Test
+ call test_override('starting', 0)
+ endfunc
*** ../vim-8.0.0676/src/version.c 2017-06-25 20:56:41.009213721 +0200
--- src/version.c 2017-06-25 20:59:20.759962062 +0200
***************
*** 766,767 ****
--- 766,769 ----
{ /* Add new patch number below this line */
+ /**/
+ 677,
/**/
--
>From "know your smileys":
:~) A man with a tape recorder up his nose
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.