To: vim_dev@googlegroups.com Subject: Patch 8.0.0687 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0687 Problem: Minor issues related to quickfix. Solution: Set the proper return status for all cases in setqflist() and at test cases for this. Move the "adding" flag outside of FEAT_WINDOWS. Minor update to the setqflist() help text. (Yegappan Lakshmanan) Files: runtime/doc/eval.txt, src/quickfix.c, src/testdir/test_quickfix.vim *** ../vim-8.0.0686/runtime/doc/eval.txt 2017-06-25 20:56:41.005213752 +0200 --- runtime/doc/eval.txt 2017-06-28 21:20:37.992947375 +0200 *************** *** 7004,7010 **** title quickfix list title text Unsupported keys in {what} are ignored. If the "nr" item is not present, then the current quickfix list ! is modified. Examples: > :call setqflist([], 'r', {'title': 'My search'}) --- 7008,7015 ---- title quickfix list title text Unsupported keys in {what} are ignored. If the "nr" item is not present, then the current quickfix list ! is modified. When creating a new quickfix list, "nr" can be ! set to a value one greater than the quickfix stack size. Examples: > :call setqflist([], 'r', {'title': 'My search'}) *** ../vim-8.0.0686/src/quickfix.c 2017-06-25 21:17:18.575532148 +0200 --- src/quickfix.c 2017-06-28 21:20:37.996947345 +0200 *************** *** 1163,1170 **** qffields_T fields; #ifdef FEAT_WINDOWS qfline_T *old_last = NULL; - int adding = FALSE; #endif static efm_T *fmt_first = NULL; char_u *efm; static char_u *last_efm = NULL; --- 1163,1170 ---- qffields_T fields; #ifdef FEAT_WINDOWS qfline_T *old_last = NULL; #endif + int adding = FALSE; static efm_T *fmt_first = NULL; char_u *efm; static char_u *last_efm = NULL; *************** *** 1199,1212 **** if (newlist || qi->qf_curlist == qi->qf_listcount) /* make place for a new list */ qf_new_list(qi, qf_title); ! #ifdef FEAT_WINDOWS ! else if (qi->qf_lists[qi->qf_curlist].qf_count > 0) { /* Adding to existing list, use last entry. */ adding = TRUE; ! old_last = qi->qf_lists[qi->qf_curlist].qf_last; ! } #endif /* Use the local value of 'errorformat' if it's set. */ if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL) --- 1199,1213 ---- if (newlist || qi->qf_curlist == qi->qf_listcount) /* make place for a new list */ qf_new_list(qi, qf_title); ! else { /* Adding to existing list, use last entry. */ adding = TRUE; ! #ifdef FEAT_WINDOWS ! if (qi->qf_lists[qi->qf_curlist].qf_count > 0) ! old_last = qi->qf_lists[qi->qf_curlist].qf_last; #endif + } /* Use the local value of 'errorformat' if it's set. */ if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL) *************** *** 4785,4790 **** --- 4786,4793 ---- (void)get_errorlist(wp, qf_idx, l); dict_add_list(retdict, "items", l); } + else + status = FAIL; } if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) *************** *** 4795,4803 **** if (di != NULL) { copy_tv(qi->qf_lists[qf_idx].qf_ctx, &di->di_tv); ! if (dict_add(retdict, di) == FAIL) dictitem_free(di); } } else status = dict_add_nr_str(retdict, "context", 0L, (char_u *)""); --- 4798,4809 ---- if (di != NULL) { copy_tv(qi->qf_lists[qf_idx].qf_ctx, &di->di_tv); ! status = dict_add(retdict, di); ! if (status == FAIL) dictitem_free(di); } + else + status = FAIL; } else status = dict_add_nr_str(retdict, "context", 0L, (char_u *)""); *************** *** 5020,5025 **** --- 5026,5032 ---- if (ctx != NULL) copy_tv(&di->di_tv, ctx); qi->qf_lists[qf_idx].qf_ctx = ctx; + retval = OK; } return retval; *** ../vim-8.0.0686/src/testdir/test_quickfix.vim 2017-06-25 21:17:18.579532117 +0200 --- src/testdir/test_quickfix.vim 2017-06-28 21:20:37.996947345 +0200 *************** *** 1720,1726 **** Xopen wincmd p call g:Xsetlist([{'filename':'foo', 'lnum':27}]) ! call g:Xsetlist([], 'a', {'title' : 'Sample'}) let d = g:Xgetlist({"title":1}) call assert_equal('Sample', d.title) --- 1720,1727 ---- Xopen wincmd p call g:Xsetlist([{'filename':'foo', 'lnum':27}]) ! let s = g:Xsetlist([], 'a', {'title' : 'Sample'}) ! call assert_equal(0, s) let d = g:Xgetlist({"title":1}) call assert_equal('Sample', d.title) *************** *** 1774,1780 **** endif " Context related tests ! call g:Xsetlist([], 'a', {'context':[1,2,3]}) call test_garbagecollect_now() let d = g:Xgetlist({'context':1}) call assert_equal([1,2,3], d.context) --- 1775,1782 ---- endif " Context related tests ! let s = g:Xsetlist([], 'a', {'context':[1,2,3]}) ! call assert_equal(0, s) call test_garbagecollect_now() let d = g:Xgetlist({'context':1}) call assert_equal([1,2,3], d.context) *************** *** 1839,1846 **** " Test for setting/getting items Xexpr "" let qfprev = g:Xgetlist({'nr':0}) ! call g:Xsetlist([], ' ', {'title':'Green', \ 'items' : [{'filename':'F1', 'lnum':10}]}) let qfcur = g:Xgetlist({'nr':0}) call assert_true(qfcur.nr == qfprev.nr + 1) let l = g:Xgetlist({'items':1}) --- 1841,1849 ---- " Test for setting/getting items Xexpr "" let qfprev = g:Xgetlist({'nr':0}) ! let s = g:Xsetlist([], ' ', {'title':'Green', \ 'items' : [{'filename':'F1', 'lnum':10}]}) + call assert_equal(0, s) let qfcur = g:Xgetlist({'nr':0}) call assert_true(qfcur.nr == qfprev.nr + 1) let l = g:Xgetlist({'items':1}) *** ../vim-8.0.0686/src/version.c 2017-06-28 20:45:22.289088662 +0200 --- src/version.c 2017-06-28 21:22:55.099900017 +0200 *************** *** 766,767 **** --- 766,769 ---- { /* Add new patch number below this line */ + /**/ + 687, /**/ -- From "know your smileys": 8<}} Glasses, big nose, beard /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///