]> granicus.if.org Git - vim/commitdiff
patch 8.0.0017 v8.0.0017
authorBram Moolenaar <Bram@vim.org>
Tue, 27 Sep 2016 19:28:56 +0000 (21:28 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 27 Sep 2016 19:28:56 +0000 (21:28 +0200)
Problem:    Cannot get the number of the current quickfix or location list.
Solution:   Use the current list if "nr" in "what" is zero. (Yegappan
            Lakshmanan)  Remove debug command from test.

runtime/doc/eval.txt
src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index 43d1883273b9fffadd5be945258b01a28ba598ee..f694ca56f5b8643e2fa66cf79acb6540425fbbcc 100644 (file)
@@ -4516,7 +4516,8 @@ getqflist([{what}])                                       *getqflist()*
                If the optional {what} dictionary argument is supplied, then
                returns only the items listed in {what} as a dictionary. The
                following string items are supported in {what}:
-                       nr      get information for this quickfix list
+                       nr      get information for this quickfix list; zero
+                               means the current quickfix list
                        title   get the list title
                        winid   get the |window-ID| (if opened)
                        all     all of the above quickfix properties
index 51c894bc63e396f1f63cd2fc469b7d20295ff7be..52abbebd1de3ea90925137efc878cba34908043a 100644 (file)
@@ -4591,9 +4591,13 @@ get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
        /* Use the specified quickfix/location list */
        if (di->di_tv.v_type == VAR_NUMBER)
        {
-           qf_idx = di->di_tv.vval.v_number - 1;
-           if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
-               return FAIL;
+           /* for zero use the current list */
+           if (di->di_tv.vval.v_number != 0)
+           {
+               qf_idx = di->di_tv.vval.v_number - 1;
+               if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
+                   return FAIL;
+           }
            flags |= QF_GETLIST_NR;
        }
        else
index affd8e633f463c510d5be06299413d08e7f54a85..4a39ac439e3fdb134e3437799f43594a68ebcf35 100644 (file)
@@ -1429,12 +1429,10 @@ function! Test_two_windows()
   laddexpr 'one.txt:3:one one one'
 
   let loc_one = getloclist(one_id)
-echo string(loc_one)
   call assert_equal('Xone/a/one.txt', bufname(loc_one[1].bufnr))
   call assert_equal(3, loc_one[1].lnum)
 
   let loc_two = getloclist(two_id)
-echo string(loc_two)
   call assert_equal('Xtwo/a/two.txt', bufname(loc_two[1].bufnr))
   call assert_equal(5, loc_two[1].lnum)
 
@@ -1534,6 +1532,11 @@ function Xproperty_tests(cchar)
     call assert_equal('N1', g:Xgetlist({'all':1}).title)
     call g:Xsetlist([], ' ', {'title' : 'N2'})
     call assert_equal(qfnr + 1, g:Xgetlist({'all':1}).nr)
+
+    let res = g:Xgetlist({'nr': 0})
+    call assert_equal(qfnr + 1, res.nr)
+    call assert_equal(['nr'], keys(res))
+
     call g:Xsetlist([], ' ', {'title' : 'N3'})
     call assert_equal('N2', g:Xgetlist({'nr':2, 'title':1}).title)
 
@@ -1546,7 +1549,7 @@ function Xproperty_tests(cchar)
     call assert_equal({}, g:Xgetlist({'abc':1}))
 
     if a:cchar == 'l'
-       call assert_equal({}, getloclist(99, ['title']))
+       call assert_equal({}, getloclist(99, {'title': 1}))
     endif
 endfunction
 
index 2ae056a6ca4021b6c46ad536f2c1deb169586e51..12c5505efed4d948be65ded8ffc83385cfb48bbb 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    17,
 /**/
     16,
 /**/