diff options
author | James McCoy <jamessan@jamessan.com> | 2016-12-12 10:56:00 -0500 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2016-12-27 14:10:00 -0500 |
commit | e89efe75f9fd872e2c7323ea525b35af90e8afa0 (patch) | |
tree | ec400ad806e769f266f6dcca8f942f53ee7eaf7a | |
parent | 9ef371fd545034519e4259da001a52e9f7838ffe (diff) | |
download | rneovim-e89efe75f9fd872e2c7323ea525b35af90e8afa0.tar.gz rneovim-e89efe75f9fd872e2c7323ea525b35af90e8afa0.tar.bz2 rneovim-e89efe75f9fd872e2c7323ea525b35af90e8afa0.zip |
vim-patch:7.4.1752
Problem: When adding to the quickfix list the current position is reset.
Solution: Do not reset the position when not needed. (Yegappan Lakshmanan)
https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28
-rw-r--r-- | src/nvim/quickfix.c | 26 | ||||
-rw-r--r-- | src/nvim/testdir/test_quickfix.vim | 48 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
3 files changed, 64 insertions, 12 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index f0d77f9e2b..b97530b700 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -786,7 +786,7 @@ qf_init_end: xfree(pattern); xfree(fmtstr); - qf_update_buffer(qi); + qf_update_buffer(qi, true); return retval; } @@ -1927,7 +1927,7 @@ static void qf_msg(qf_info_T *qi) smsg(_("error list %d of %d; %d errors"), qi->qf_curlist + 1, qi->qf_listcount, qi->qf_lists[qi->qf_curlist].qf_count); - qf_update_buffer(qi); + qf_update_buffer(qi, true); } /* @@ -2314,7 +2314,7 @@ static buf_T *qf_find_buf(qf_info_T *qi) /* * Find the quickfix buffer. If it exists, update the contents. */ -static void qf_update_buffer(qf_info_T *qi) +static void qf_update_buffer(qf_info_T *qi, bool update_cursor) { buf_T *buf; win_T *win; @@ -2337,8 +2337,9 @@ static void qf_update_buffer(qf_info_T *qi) /* restore curwin/curbuf and a few other things */ aucmd_restbuf(&aco); - - (void)qf_win_pos_update(qi, 0); + if (update_cursor) { + (void)qf_win_pos_update(qi, 0); + } } } @@ -3240,7 +3241,7 @@ void ex_vimgrep(exarg_T *eap) qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start; qi->qf_lists[qi->qf_curlist].qf_index = 1; - qf_update_buffer(qi); + qf_update_buffer(qi, true); if (au_name != NULL) apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, @@ -3624,12 +3625,15 @@ int set_errorlist(win_T *wp, list_T *list, int action, char_u *title) qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE; else qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; - qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start; - if (qi->qf_lists[qi->qf_curlist].qf_count > 0) { - qi->qf_lists[qi->qf_curlist].qf_index = 1; + if (action != 'a') { + qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start; + if (qi->qf_lists[qi->qf_curlist].qf_count > 0) { + qi->qf_lists[qi->qf_curlist].qf_index = 1; + } } - qf_update_buffer(qi); + // Don't update the cursor in quickfix window when appending entries + qf_update_buffer(qi, (action != 'a')); return retval; } @@ -3885,7 +3889,7 @@ void ex_helpgrep(exarg_T *eap) /* Darn, some plugin changed the value. */ free_string_option(save_cpo); - qf_update_buffer(qi); + qf_update_buffer(qi, true); if (au_name != NULL) { apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 9dbd00b001..9955b4f775 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -679,3 +679,51 @@ func Test_cgetexpr_works() " this must not crash Vim cgetexpr [$x] endfunc + +" Tests for the setqflist() and setloclist() functions +function SetXlistTests(cchar, bnum) + if a:cchar == 'c' + let Xsetlist = function('setqflist') + let Xgetlist = function('getqflist') + let Xnext = 'cnext' + else + let Xsetlist = function('setloclist', [0]) + let Xgetlist = function('getloclist', [0]) + let Xnext = 'lnext' + endif + + call Xsetlist([{'bufnr': a:bnum, 'lnum': 1}, + \ {'bufnr': a:bnum, 'lnum': 2}]) + let l = Xgetlist() + call assert_equal(2, len(l)) + call assert_equal(2, l[1].lnum) + + exe Xnext + call Xsetlist([{'bufnr': a:bnum, 'lnum': 3}], 'a') + let l = Xgetlist() + call assert_equal(3, len(l)) + exe Xnext + call assert_equal(3, line('.')) + + call Xsetlist([{'bufnr': a:bnum, 'lnum': 3}, + \ {'bufnr': a:bnum, 'lnum': 4}, + \ {'bufnr': a:bnum, 'lnum': 5}], 'r') + let l = Xgetlist() + call assert_equal(3, len(l)) + call assert_equal(5, l[2].lnum) + + call Xsetlist([]) + let l = Xgetlist() + call assert_equal(0, len(l)) +endfunction + +function Test_setqflist() + new Xtestfile | only + let bnum = bufnr('%') + call setline(1, range(1,5)) + + call SetXlistTests('c', bnum) + call SetXlistTests('l', bnum) + + call delete('Xtestfile') +endfunction diff --git a/src/nvim/version.c b/src/nvim/version.c index ed1d7448ea..d10d5cf75b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -689,7 +689,7 @@ static int included_patches[] = { 1754, 1753, // 1753, - // 1752, + 1752, 1751, // 1750 NA // 1749 NA |