diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-09-08 11:19:55 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-09-08 11:31:24 -0400 |
commit | 213a66441fb1b01ed30ed1beef4d1aa540549171 (patch) | |
tree | a5a57875d02db45d1fce573350d8cba6c4bf7b62 /src | |
parent | 1790f81f56087e45f24e82fb8d5f99a9e0f59d49 (diff) | |
download | rneovim-213a66441fb1b01ed30ed1beef4d1aa540549171.tar.gz rneovim-213a66441fb1b01ed30ed1beef4d1aa540549171.tar.bz2 rneovim-213a66441fb1b01ed30ed1beef4d1aa540549171.zip |
vim-patch:8.0.1031: "text" argument for getqflist() is confusing
Problem: "text" argument for getqflist() is confusing. (Lcd47)
Solution: Use "lines" instead. (Yegappan Lakshmanan)
https://github.com/vim/vim/commit/2c809b7c7d2bb5e4b7fd09c3d312cadecf0c1ff0
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/quickfix.c | 22 | ||||
-rw-r--r-- | src/nvim/testdir/test_quickfix.vim | 55 |
2 files changed, 35 insertions, 42 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index ec11e5d849..5b701695fd 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4122,15 +4122,12 @@ enum { }; // Parse text from 'di' and return the quickfix list items -static int qf_get_list_from_text(dictitem_T *di, dict_T *retdict) +static int qf_get_list_from_lines(dictitem_T *di, dict_T *retdict) { int status = FAIL; - // Only string and list values are supported - if ((di->di_tv.v_type == VAR_STRING - && di->di_tv.vval.v_string != NULL) - || (di->di_tv.v_type == VAR_LIST - && di->di_tv.vval.v_list != NULL)) { + // Only a List value is supported + if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL) { list_T *l = tv_list_alloc(kListLenMayKnow); qf_info_T *qi = xmalloc(sizeof(*qi)); memset(qi, 0, sizeof(*qi)); @@ -4158,8 +4155,8 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) qf_info_T *qi = &ql_info; dictitem_T *di; - if ((di = tv_dict_find(what, S_LEN("text"))) != NULL) { - return qf_get_list_from_text(di, retdict); + if ((di = tv_dict_find(what, S_LEN("lines"))) != NULL) { + return qf_get_list_from_lines(di, retdict); } if (wp != NULL) { @@ -4474,12 +4471,9 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action, } } - if ((di = tv_dict_find(what, S_LEN("text"))) != NULL) { - // Only string and list values are supported - if ((di->di_tv.v_type == VAR_STRING - && di->di_tv.vval.v_string != NULL) - || (di->di_tv.v_type == VAR_LIST - && di->di_tv.vval.v_list != NULL)) { + if ((di = tv_dict_find(what, S_LEN("lines"))) != NULL) { + // Only a List value is supported + if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL) { if (action == 'r') { qf_free_items(qi, qf_idx); } diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index c6324b1dc2..f1dc3d37be 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -2281,25 +2281,26 @@ func Xsetexpr_tests(cchar) call s:setup_commands(a:cchar) let t = ["File1:10:Line10", "File1:20:Line20"] - call g:Xsetlist([], ' ', {'text' : t}) - call g:Xsetlist([], 'a', {'text' : "File1:30:Line30"}) + call g:Xsetlist([], ' ', {'lines' : t}) + call g:Xsetlist([], 'a', {'lines' : ["File1:30:Line30"]}) let l = g:Xgetlist() call assert_equal(3, len(l)) call assert_equal(20, l[1].lnum) call assert_equal('Line30', l[2].text) - call g:Xsetlist([], 'r', {'text' : "File2:5:Line5"}) + call g:Xsetlist([], 'r', {'lines' : ["File2:5:Line5"]}) let l = g:Xgetlist() call assert_equal(1, len(l)) call assert_equal('Line5', l[0].text) - call assert_equal(-1, g:Xsetlist([], 'a', {'text' : 10})) + call assert_equal(-1, g:Xsetlist([], 'a', {'lines' : 10})) + call assert_equal(-1, g:Xsetlist([], 'a', {'lines' : "F1:10:L10"})) call g:Xsetlist([], 'f') " Add entries to multiple lists - call g:Xsetlist([], 'a', {'nr' : 1, 'text' : ["File1:10:Line10"]}) - call g:Xsetlist([], 'a', {'nr' : 2, 'text' : ["File2:20:Line20"]}) - call g:Xsetlist([], 'a', {'nr' : 1, 'text' : ["File1:15:Line15"]}) - call g:Xsetlist([], 'a', {'nr' : 2, 'text' : ["File2:25:Line25"]}) + call g:Xsetlist([], 'a', {'nr' : 1, 'lines' : ["File1:10:Line10"]}) + call g:Xsetlist([], 'a', {'nr' : 2, 'lines' : ["File2:20:Line20"]}) + call g:Xsetlist([], 'a', {'nr' : 1, 'lines' : ["File1:15:Line15"]}) + call g:Xsetlist([], 'a', {'nr' : 2, 'lines' : ["File2:25:Line25"]}) call assert_equal('Line15', g:Xgetlist({'nr':1, 'items':1}).items[1].text) call assert_equal('Line25', g:Xgetlist({'nr':2, 'items':1}).items[1].text) endfunc @@ -2316,10 +2317,10 @@ func Xmultidirstack_tests(cchar) call g:Xsetlist([], 'f') Xexpr "" | Xexpr "" - call g:Xsetlist([], 'a', {'nr' : 1, 'text' : "Entering dir 'Xone/a'"}) - call g:Xsetlist([], 'a', {'nr' : 2, 'text' : "Entering dir 'Xtwo/a'"}) - call g:Xsetlist([], 'a', {'nr' : 1, 'text' : "one.txt:3:one one one"}) - call g:Xsetlist([], 'a', {'nr' : 2, 'text' : "two.txt:5:two two two"}) + call g:Xsetlist([], 'a', {'nr' : 1, 'lines' : ["Entering dir 'Xone/a'"]}) + call g:Xsetlist([], 'a', {'nr' : 2, 'lines' : ["Entering dir 'Xtwo/a'"]}) + call g:Xsetlist([], 'a', {'nr' : 1, 'lines' : ["one.txt:3:one one one"]}) + call g:Xsetlist([], 'a', {'nr' : 2, 'lines' : ["two.txt:5:two two two"]}) let l1 = g:Xgetlist({'nr':1, 'items':1}) let l2 = g:Xgetlist({'nr':2, 'items':1}) @@ -2353,10 +2354,10 @@ func Xmultifilestack_tests(cchar) call g:Xsetlist([], 'f') Xexpr "" | Xexpr "" - call g:Xsetlist([], 'a', {'nr' : 1, 'text' : "[one.txt]"}) - call g:Xsetlist([], 'a', {'nr' : 2, 'text' : "[two.txt]"}) - call g:Xsetlist([], 'a', {'nr' : 1, 'text' : "(3,5) one one one"}) - call g:Xsetlist([], 'a', {'nr' : 2, 'text' : "(5,9) two two two"}) + call g:Xsetlist([], 'a', {'nr' : 1, 'lines' : ["[one.txt]"]}) + call g:Xsetlist([], 'a', {'nr' : 2, 'lines' : ["[two.txt]"]}) + call g:Xsetlist([], 'a', {'nr' : 1, 'lines' : ["(3,5) one one one"]}) + call g:Xsetlist([], 'a', {'nr' : 2, 'lines' : ["(5,9) two two two"]}) let l1 = g:Xgetlist({'nr':1, 'items':1}) let l2 = g:Xgetlist({'nr':2, 'items':1}) @@ -2505,28 +2506,26 @@ endfunc " Test for getting the quickfix list items from some text without modifying " the quickfix stack -func XgetListFromText(cchar) +func XgetListFromLines(cchar) call s:setup_commands(a:cchar) call g:Xsetlist([], 'f') - let l = g:Xgetlist({'text' : "File1:10:Line10"}).items - call assert_equal(1, len(l)) - call assert_equal('Line10', l[0].text) - - let l = g:Xgetlist({'text' : ["File2:20:Line20", "File2:30:Line30"]}).items + let l = g:Xgetlist({'lines' : ["File2:20:Line20", "File2:30:Line30"]}).items call assert_equal(2, len(l)) call assert_equal(30, l[1].lnum) - call assert_equal({}, g:Xgetlist({'text' : 10})) - call assert_equal([], g:Xgetlist({'text' : []}).items) + call assert_equal({}, g:Xgetlist({'lines' : 10})) + call assert_equal({}, g:Xgetlist({'lines' : 'File1:10:Line10'})) + call assert_equal([], g:Xgetlist({'lines' : []}).items) + call assert_equal([], g:Xgetlist({'lines' : [10, 20]}).items) " Make sure that the quickfix stack is not modified call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr) endfunc -func Test_get_list_from_text() - call XgetListFromText('c') - call XgetListFromText('l') +func Test_get_list_from_lines() + call XgetListFromLines('c') + call XgetListFromLines('l') endfunc " Tests for the quickfix list id @@ -2549,7 +2548,7 @@ func Xqfid_tests(cchar) call g:Xsetlist([], 'a', {'id':start_id, 'context':[1,2]}) call assert_equal([1,2], g:Xgetlist({'nr':1, 'context':1}).context) - call g:Xsetlist([], 'a', {'id':start_id+1, 'text':'F1:10:L10'}) + call g:Xsetlist([], 'a', {'id':start_id+1, 'lines':['F1:10:L10']}) call assert_equal('L10', g:Xgetlist({'nr':2, 'items':1}).items[0].text) call assert_equal(-1, g:Xsetlist([], 'a', {'id':999, 'title':'Vim'})) call assert_equal(-1, g:Xsetlist([], 'a', {'id':'abc', 'title':'Vim'})) |