From 7f7c3325d3f1baba32263a3457cfc4d90ecd5ff1 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 18 Apr 2016 19:27:24 +0200 Subject: [PATCH 1/4] patch 7.4.1750 Problem: When a buffer gets updated while in command line mode, the screen may be messed up. Solution: Postpone the redraw when the screen is scrolled. --- src/channel.c | 16 +++++++++------- src/version.c | 2 ++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/channel.c b/src/channel.c index 72484ecb04..892c09ab7e 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1431,6 +1431,7 @@ channel_write_new_lines(buf_T *buf) /* * Invoke the "callback" on channel "channel". + * This does not redraw but sets channel_need_redraw; */ static void invoke_callback(channel_T *channel, char_u *callback, partial_T *partial, @@ -1445,8 +1446,7 @@ invoke_callback(channel_T *channel, char_u *callback, partial_T *partial, call_func(callback, (int)STRLEN(callback), &rettv, 2, argv, 0L, 0L, &dummy, TRUE, partial, NULL); clear_tv(&rettv); - - redraw_after_callback(); + channel_need_redraw = TRUE; } /* @@ -2009,6 +2009,10 @@ channel_exe_cmd(channel_T *channel, int part, typval_T *argv) } } +/* + * Invoke the callback at "cbhead". + * Does not redraw but sets channel_need_redraw. + */ static void invoke_one_time_callback( channel_T *channel, @@ -2099,6 +2103,7 @@ append_to_buffer(buf_T *buffer, char_u *msg, channel_T *channel) /* * Invoke a callback for "channel"/"part" if needed. + * This does not redraw but sets channel_need_redraw when redraw is needed. * Return TRUE when a message was handled, there might be another one. */ static int @@ -3468,13 +3473,10 @@ channel_parse_messages(void) } } - if (channel_need_redraw && must_redraw) + if (channel_need_redraw) { channel_need_redraw = FALSE; - update_screen(0); - setcursor(); - cursor_on(); - out_flush(); + redraw_after_callback(); } return ret; diff --git a/src/version.c b/src/version.c index fa09585486..695d0b731d 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1750, /**/ 1749, /**/ From def5abe0a2727041ecee69afdccfca405333bd24 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 18 Apr 2016 19:46:15 +0200 Subject: [PATCH 2/4] patch 7.4.1751 Problem: Crash when 'tagstack' is off. (Dominique Pelle) Solution: Fix it. (Hirohito Higashi) --- src/tag.c | 8 ++++++++ src/testdir/test_alot.vim | 1 + src/version.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/src/tag.c b/src/tag.c index 4224c6fc25..8f4495ee2c 100644 --- a/src/tag.c +++ b/src/tag.c @@ -200,6 +200,14 @@ do_tag( { use_tagstack = FALSE; new_tag = TRUE; +#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) + if (g_do_tagpreview != 0) + { + vim_free(ptag_entry.tagname); + if ((ptag_entry.tagname = vim_strsave(tag)) == NULL) + goto end_do_tag; + } +#endif } else { diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index 5637a8e0c3..cb377716b5 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -27,6 +27,7 @@ source test_sort.vim source test_statusline.vim source test_syn_attr.vim source test_tabline.vim +source test_tagjump.vim source test_timers.vim source test_undolevels.vim source test_unlet.vim diff --git a/src/version.c b/src/version.c index 695d0b731d..7918d99ac1 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1751, /**/ 1750, /**/ From c1808d5822ed9534ef7f0fe509b15bee92a5cc28 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 18 Apr 2016 20:04:00 +0200 Subject: [PATCH 3/4] 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) --- src/quickfix.c | 27 ++++++++++++-------- src/testdir/test_quickfix.vim | 48 +++++++++++++++++++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 66 insertions(+), 11 deletions(-) diff --git a/src/quickfix.c b/src/quickfix.c index 00762bda45..510d8ddcb2 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -126,7 +126,7 @@ static int qf_win_pos_update(qf_info_T *qi, int old_qf_index); static int is_qf_win(win_T *win, qf_info_T *qi); static win_T *qf_find_win(qf_info_T *qi); static buf_T *qf_find_buf(qf_info_T *qi); -static void qf_update_buffer(qf_info_T *qi); +static void qf_update_buffer(qf_info_T *qi, int update_cursor); static void qf_set_title_var(qf_info_T *qi); static void qf_fill_buffer(qf_info_T *qi); #endif @@ -880,7 +880,7 @@ qf_init_end: vim_free(fmtstr); #ifdef FEAT_WINDOWS - qf_update_buffer(qi); + qf_update_buffer(qi, TRUE); #endif return retval; @@ -2176,7 +2176,7 @@ qf_msg(qf_info_T *qi) qi->qf_curlist + 1, qi->qf_listcount, qi->qf_lists[qi->qf_curlist].qf_count); #ifdef FEAT_WINDOWS - qf_update_buffer(qi); + qf_update_buffer(qi, TRUE); #endif } @@ -2606,7 +2606,7 @@ 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) +qf_update_buffer(qf_info_T *qi, int update_cursor) { buf_T *buf; win_T *win; @@ -2633,7 +2633,8 @@ 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); } } @@ -3675,7 +3676,7 @@ ex_vimgrep(exarg_T *eap) qi->qf_lists[qi->qf_curlist].qf_index = 1; #ifdef FEAT_WINDOWS - qf_update_buffer(qi); + qf_update_buffer(qi, TRUE); #endif #ifdef FEAT_AUTOCMD @@ -4115,12 +4116,16 @@ set_errorlist( 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; + } #ifdef FEAT_WINDOWS - qf_update_buffer(qi); + /* Don't update the cursor in quickfix window when appending entries */ + qf_update_buffer(qi, (action != 'a')); #endif return retval; @@ -4427,7 +4432,7 @@ ex_helpgrep(exarg_T *eap) free_string_option(save_cpo); #ifdef FEAT_WINDOWS - qf_update_buffer(qi); + qf_update_buffer(qi, TRUE); #endif #ifdef FEAT_AUTOCMD diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim index 8da1b6fff4..17b07630f9 100644 --- a/src/testdir/test_quickfix.vim +++ b/src/testdir/test_quickfix.vim @@ -697,3 +697,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/version.c b/src/version.c index 7918d99ac1..0c50f1a281 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1752, /**/ 1751, /**/ From 8d8aa0a367380f23f0af428fcb66a1a0615bf872 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 18 Apr 2016 20:21:12 +0200 Subject: [PATCH 4/4] Add missing test file. --- src/testdir/test_tagjump.vim | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/testdir/test_tagjump.vim diff --git a/src/testdir/test_tagjump.vim b/src/testdir/test_tagjump.vim new file mode 100644 index 0000000000..d8a333f44c --- /dev/null +++ b/src/testdir/test_tagjump.vim @@ -0,0 +1,9 @@ +" Tests for tagjump (tags and special searches) + +" SEGV occurs in older versions. (At least 7.4.1748 or older) +func Test_ptag_with_notagstack() + set notagstack + call assert_fails('ptag does_not_exist_tag_name', 'E426') + set tagstack&vim +endfunc +" vim: sw=2 et