Skip to content

Commit 890680c

Browse files
committed
patch 8.0.0017
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.
1 parent 0e77b76 commit 890680c

4 files changed

Lines changed: 17 additions & 7 deletions

File tree

runtime/doc/eval.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4516,7 +4516,8 @@ getqflist([{what}]) *getqflist()*
45164516
If the optional {what} dictionary argument is supplied, then
45174517
returns only the items listed in {what} as a dictionary. The
45184518
following string items are supported in {what}:
4519-
nr get information for this quickfix list
4519+
nr get information for this quickfix list; zero
4520+
means the current quickfix list
45204521
title get the list title
45214522
winid get the |window-ID| (if opened)
45224523
all all of the above quickfix properties

src/quickfix.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4591,9 +4591,13 @@ get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
45914591
/* Use the specified quickfix/location list */
45924592
if (di->di_tv.v_type == VAR_NUMBER)
45934593
{
4594-
qf_idx = di->di_tv.vval.v_number - 1;
4595-
if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
4596-
return FAIL;
4594+
/* for zero use the current list */
4595+
if (di->di_tv.vval.v_number != 0)
4596+
{
4597+
qf_idx = di->di_tv.vval.v_number - 1;
4598+
if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
4599+
return FAIL;
4600+
}
45974601
flags |= QF_GETLIST_NR;
45984602
}
45994603
else

src/testdir/test_quickfix.vim

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,12 +1429,10 @@ function! Test_two_windows()
14291429
laddexpr 'one.txt:3:one one one'
14301430

14311431
let loc_one = getloclist(one_id)
1432-
echo string(loc_one)
14331432
call assert_equal('Xone/a/one.txt', bufname(loc_one[1].bufnr))
14341433
call assert_equal(3, loc_one[1].lnum)
14351434

14361435
let loc_two = getloclist(two_id)
1437-
echo string(loc_two)
14381436
call assert_equal('Xtwo/a/two.txt', bufname(loc_two[1].bufnr))
14391437
call assert_equal(5, loc_two[1].lnum)
14401438

@@ -1534,6 +1532,11 @@ function Xproperty_tests(cchar)
15341532
call assert_equal('N1', g:Xgetlist({'all':1}).title)
15351533
call g:Xsetlist([], ' ', {'title' : 'N2'})
15361534
call assert_equal(qfnr + 1, g:Xgetlist({'all':1}).nr)
1535+
1536+
let res = g:Xgetlist({'nr': 0})
1537+
call assert_equal(qfnr + 1, res.nr)
1538+
call assert_equal(['nr'], keys(res))
1539+
15371540
call g:Xsetlist([], ' ', {'title' : 'N3'})
15381541
call assert_equal('N2', g:Xgetlist({'nr':2, 'title':1}).title)
15391542

@@ -1546,7 +1549,7 @@ function Xproperty_tests(cchar)
15461549
call assert_equal({}, g:Xgetlist({'abc':1}))
15471550

15481551
if a:cchar == 'l'
1549-
call assert_equal({}, getloclist(99, ['title']))
1552+
call assert_equal({}, getloclist(99, {'title': 1}))
15501553
endif
15511554
endfunction
15521555

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
17,
767769
/**/
768770
16,
769771
/**/

0 commit comments

Comments
 (0)