To: vim_dev@googlegroups.com Subject: Patch 8.2.3547 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3547 Problem: Opening the quickfix window triggers BufWinEnter twice. (Yorick Peterse) Solution: Only trigger BufWinEnter with "quickfix". (closes #9022) Files: src/ex_cmds.c, src/vim.h, src/quickfix.c, src/buffer.c, src/testdir/test_quickfix.vim *** ../vim-8.2.3546/src/ex_cmds.c 2021-10-13 15:37:10.662858907 +0100 --- src/ex_cmds.c 2021-10-20 21:44:56.943654051 +0100 *************** *** 2473,2478 **** --- 2473,2479 ---- * ECMD_FORCEIT: ! used for Ex command * ECMD_ADDBUF: don't edit, just add to buffer list * ECMD_ALTBUF: like ECMD_ADDBUF and also set the alternate file + * ECMD_NOWINENTER: Do not trigger BufWinEnter * oldwin: Should be "curwin" when editing a new buffer in the current * window, NULL when splitting the window first. When not NULL info * of the previous buffer for "oldwin" is stored. *************** *** 3030,3035 **** --- 3031,3038 ---- /* * Open the buffer and read the file. */ + if (flags & ECMD_NOWINENTER) + readfile_flags |= READ_NOWINENTER; #if defined(FEAT_EVAL) if (should_abort(open_buffer(FALSE, eap, readfile_flags))) retval = FAIL; *************** *** 3051,3060 **** // changed by the user. do_modelines(OPT_WINONLY); ! apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf, ! &retval); ! apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf, ! &retval); } check_arg_idx(curwin); --- 3054,3064 ---- // changed by the user. do_modelines(OPT_WINONLY); ! apply_autocmds_retval(EVENT_BUFENTER, NULL, NULL, FALSE, ! curbuf, &retval); ! if ((flags & ECMD_NOWINENTER) == 0) ! apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, FALSE, ! curbuf, &retval); } check_arg_idx(curwin); *** ../vim-8.2.3546/src/vim.h 2021-10-17 17:20:20.395745556 +0100 --- src/vim.h 2021-10-20 21:44:18.435390327 +0100 *************** *** 977,982 **** --- 977,983 ---- #define READ_DUMMY 0x10 // reading into a dummy buffer #define READ_KEEP_UNDO 0x20 // keep undo info #define READ_FIFO 0x40 // read from fifo or socket + #define READ_NOWINENTER 0x80 // do not trigger BufWinEnter // Values for change_indent() #define INDENT_SET 1 // set indent *************** *** 1043,1048 **** --- 1044,1050 ---- #define ECMD_FORCEIT 0x08 // ! used in Ex command #define ECMD_ADDBUF 0x10 // don't edit, just add to buffer list #define ECMD_ALTBUF 0x20 // like ECMD_ADDBUF and set the alternate file + #define ECMD_NOWINENTER 0x40 // do not trigger BufWinEnter // for lnum argument in do_ecmd() #define ECMD_LASTL (linenr_T)0 // use last position in loaded file *** ../vim-8.2.3546/src/quickfix.c 2021-07-27 21:00:39.749712387 +0100 --- src/quickfix.c 2021-10-20 21:53:06.320104407 +0100 *************** *** 4199,4211 **** { // Use the existing quickfix buffer if (do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE, ! ECMD_HIDE + ECMD_OLDBUF, oldwin) == FAIL) return FAIL; } else { // Create a new quickfix buffer ! if (do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin) == FAIL) return FAIL; // save the number of the new buffer --- 4199,4212 ---- { // Use the existing quickfix buffer if (do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE, ! ECMD_HIDE + ECMD_OLDBUF + ECMD_NOWINENTER, oldwin) == FAIL) return FAIL; } else { // Create a new quickfix buffer ! if (do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE + ECMD_NOWINENTER, ! oldwin) == FAIL) return FAIL; // save the number of the new buffer *** ../vim-8.2.3546/src/buffer.c 2021-10-19 20:48:48.444911729 +0100 --- src/buffer.c 2021-10-20 21:45:49.868043164 +0100 *************** *** 360,370 **** do_modelines(0); curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED); #ifdef FEAT_EVAL ! apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf, ! &retval); #else ! apply_autocmds(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf); #endif // restore curwin/curbuf and a few other things --- 360,371 ---- do_modelines(0); curbuf->b_flags &= ~(BF_CHECK_RO | BF_NEVERLOADED); + if ((flags & READ_NOWINENTER) == 0) #ifdef FEAT_EVAL ! apply_autocmds_retval(EVENT_BUFWINENTER, NULL, NULL, FALSE, ! curbuf, &retval); #else ! apply_autocmds(EVENT_BUFWINENTER, NULL, NULL, FALSE, curbuf); #endif // restore curwin/curbuf and a few other things *** ../vim-8.2.3546/src/testdir/test_quickfix.vim 2021-07-31 11:43:19.464837526 +0100 --- src/testdir/test_quickfix.vim 2021-10-20 21:52:00.219415492 +0100 *************** *** 786,791 **** --- 786,808 ---- augroup! QfBufWinEnter endfunc + func Test_bufwinenter_once() + augroup QfBufWinEnter + au! + au BufWinEnter * let g:got_afile ..= 'got ' .. expand('') + augroup END + let g:got_afile = '' + copen + call assert_equal('got quickfix', g:got_afile) + + cclose + unlet g:got_afile + augroup QfBufWinEnter + au! + augroup END + augroup! QfBufWinEnter + endfunc + func XqfTitleTests(cchar) call s:setup_commands(a:cchar) *** ../vim-8.2.3546/src/version.c 2021-10-20 17:21:20.367225487 +0100 --- src/version.c 2021-10-20 21:46:03.848150760 +0100 *************** *** 759,760 **** --- 759,762 ---- { /* Add new patch number below this line */ + /**/ + 3547, /**/ -- "You mean there really is an answer?" "Yes! But you're not going to like it!" "Oh do please tell us!" "You're really not going to like it!" "but we MUST know - tell us" "Alright, the answer is...." "yes..." "... is ..." "yes... come on!" "is 42!" (Douglas Adams - The Hitchhiker's Guide to the Galaxy) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///