diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-29 18:20:11 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-11-29 20:36:31 +0800 |
commit | 3173d07564e7cdf0834099a379f0faf480c76224 (patch) | |
tree | 2ced5358c126a6015f0b66a1e015542f039ac29f /src/nvim/quickfix.c | |
parent | 273358651af6b6d172944cd1b1b41a9869d53b10 (diff) | |
download | rneovim-3173d07564e7cdf0834099a379f0faf480c76224.tar.gz rneovim-3173d07564e7cdf0834099a379f0faf480c76224.tar.bz2 rneovim-3173d07564e7cdf0834099a379f0faf480c76224.zip |
vim-patch:9.0.0965: using one window for executing autocommands is insufficient
Problem: Using one window for executing autocommands is insufficient.
Solution: Use up to five windows for executing autocommands.
https://github.com/vim/vim/commit/e76062c078debed0df818f70e4db14ad7a7cb53a
N/A patches for version.c:
vim-patch:9.0.0966: some compilers don't allow a declaration after a label
Problem: Some compilers don't allow a declaration after a label.
Solution: Move the declaration to the start of the block. (John Marriott)
https://github.com/vim/vim/commit/f86490ed4fdab213a28f667abd055c023a73d645
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/quickfix.c')
-rw-r--r-- | src/nvim/quickfix.c | 96 |
1 files changed, 53 insertions, 43 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index f083b6792b..be6ddede2e 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3902,21 +3902,27 @@ static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last) aco_save_T aco; + bool do_fill = true; if (old_last == NULL) { // set curwin/curbuf to buf and save a few things aucmd_prepbuf(&aco, buf); + if (curbuf != buf) { + do_fill = false; // failed to find a window for "buf" + } } - qf_update_win_titlevar(qi); + if (do_fill) { + qf_update_win_titlevar(qi); - qf_fill_buffer(qf_get_curlist(qi), buf, old_last, qf_winid); - buf_inc_changedtick(buf); + qf_fill_buffer(qf_get_curlist(qi), buf, old_last, qf_winid); + buf_inc_changedtick(buf); - if (old_last == NULL) { - (void)qf_win_pos_update(qi, 0); + if (old_last == NULL) { + (void)qf_win_pos_update(qi, 0); - // restore curwin/curbuf and a few other things - aucmd_restbuf(&aco); + // restore curwin/curbuf and a few other things + aucmd_restbuf(&aco); + } } // Only redraw when added lines are visible. This avoids flickering when @@ -5463,9 +5469,11 @@ static int vgr_process_files(win_T *wp, qf_info_T *qi, vgr_args_T *cmd_args, boo // options! aco_save_T aco; aucmd_prepbuf(&aco, buf); - apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, buf->b_fname, true, buf); - do_modelines(OPT_NOWIN); - aucmd_restbuf(&aco); + if (curbuf == buf) { + apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, buf->b_fname, true, buf); + do_modelines(OPT_NOWIN); + aucmd_restbuf(&aco); + } } } } @@ -5623,41 +5631,43 @@ static buf_T *load_dummy_buffer(char *fname, char *dirname_start, char *resultin // set curwin/curbuf to buf and save a few things aco_save_T aco; aucmd_prepbuf(&aco, newbuf); - - // Need to set the filename for autocommands. - (void)setfname(curbuf, fname, NULL, false); - - // Create swap file now to avoid the ATTENTION message. - check_need_swap(true); - - // Remove the "dummy" flag, otherwise autocommands may not - // work. - curbuf->b_flags &= ~BF_DUMMY; - - bufref_T newbuf_to_wipe; - newbuf_to_wipe.br_buf = NULL; - int readfile_result = readfile(fname, NULL, (linenr_T)0, (linenr_T)0, - (linenr_T)MAXLNUM, NULL, - READ_NEW | READ_DUMMY, false); - newbuf->b_locked--; - if (readfile_result == OK - && !got_int - && !(curbuf->b_flags & BF_NEW)) { - failed = false; - if (curbuf != newbuf) { - // Bloody autocommands changed the buffer! Can happen when - // using netrw and editing a remote file. Use the current - // buffer instead, delete the dummy one after restoring the - // window stuff. - set_bufref(&newbuf_to_wipe, newbuf); - newbuf = curbuf; + if (curbuf == newbuf) { + // Need to set the filename for autocommands. + (void)setfname(curbuf, fname, NULL, false); + + // Create swap file now to avoid the ATTENTION message. + check_need_swap(true); + + // Remove the "dummy" flag, otherwise autocommands may not + // work. + curbuf->b_flags &= ~BF_DUMMY; + + bufref_T newbuf_to_wipe; + newbuf_to_wipe.br_buf = NULL; + int readfile_result = readfile(fname, NULL, (linenr_T)0, (linenr_T)0, + (linenr_T)MAXLNUM, NULL, + READ_NEW | READ_DUMMY, false); + newbuf->b_locked--; + if (readfile_result == OK + && !got_int + && !(curbuf->b_flags & BF_NEW)) { + failed = false; + if (curbuf != newbuf) { + // Bloody autocommands changed the buffer! Can happen when + // using netrw and editing a remote file. Use the current + // buffer instead, delete the dummy one after restoring the + // window stuff. + set_bufref(&newbuf_to_wipe, newbuf); + newbuf = curbuf; + } } - } - // Restore curwin/curbuf and a few other things. - aucmd_restbuf(&aco); - if (newbuf_to_wipe.br_buf != NULL && bufref_valid(&newbuf_to_wipe)) { - wipe_buffer(newbuf_to_wipe.br_buf, false); + // Restore curwin/curbuf and a few other things. + aucmd_restbuf(&aco); + + if (newbuf_to_wipe.br_buf != NULL && bufref_valid(&newbuf_to_wipe)) { + wipe_buffer(newbuf_to_wipe.br_buf, false); + } } // Add back the "dummy" flag, otherwise buflist_findname_file_id() |