aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-09-08 11:37:59 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-09-08 11:52:59 -0400
commit3794e83d9881b2f3dd695b8a2f05a7d39980f43e (patch)
treef8c03b3bebe96e9bbfe3b946c1dd19d90475df41 /src
parenta8b996160d2749e4f4592ece92a1107521b1beb4 (diff)
downloadrneovim-3794e83d9881b2f3dd695b8a2f05a7d39980f43e.tar.gz
rneovim-3794e83d9881b2f3dd695b8a2f05a7d39980f43e.tar.bz2
rneovim-3794e83d9881b2f3dd695b8a2f05a7d39980f43e.zip
vim-patch:8.0.1040: cannot use another error format in getqflist()
Problem: Cannot use another error format in getqflist(). Solution: Add the "efm" argument to getqflist(). (Yegappan Lakshmanan) https://github.com/vim/vim/commit/3653822546fb0f1005c32bb5b70dc9bfacdfc954
Diffstat (limited to 'src')
-rw-r--r--src/nvim/quickfix.c28
-rw-r--r--src/nvim/testdir/test_quickfix.vim22
2 files changed, 46 insertions, 4 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 9e415b31a1..ba2f2ba969 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -4122,18 +4122,30 @@ enum {
};
// Parse text from 'di' and return the quickfix list items
-static int qf_get_list_from_lines(dictitem_T *di, dict_T *retdict)
+static int qf_get_list_from_lines(dict_T *what, dictitem_T *di, dict_T *retdict)
{
int status = FAIL;
+ char_u *errorformat = p_efm;
+ dictitem_T *efm_di;
// Only a List value is supported
if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL) {
+ // If errorformat is supplied then use it, otherwise use the 'efm'
+ // option setting
+ if ((efm_di = tv_dict_find(what, S_LEN("efm"))) != NULL) {
+ if (efm_di->di_tv.v_type != VAR_STRING
+ || efm_di->di_tv.vval.v_string == NULL) {
+ return FAIL;
+ }
+ errorformat = efm_di->di_tv.vval.v_string;
+ }
+
list_T *l = tv_list_alloc(kListLenMayKnow);
qf_info_T *qi = xmalloc(sizeof(*qi));
memset(qi, 0, sizeof(*qi));
qi->qf_refcount++;
- if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, p_efm,
+ if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat,
true, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0) {
(void)get_errorlist(qi, NULL, 0, l);
qf_free(qi, 0);
@@ -4156,7 +4168,7 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
dictitem_T *di;
if ((di = tv_dict_find(what, S_LEN("lines"))) != NULL) {
- return qf_get_list_from_lines(di, retdict);
+ return qf_get_list_from_lines(what, di, retdict);
}
if (wp != NULL) {
@@ -4390,6 +4402,7 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action,
dictitem_T *di;
int retval = FAIL;
int newlist = false;
+ char_u *errorformat = p_efm;
if (action == ' ' || qi->qf_curlist == qi->qf_listcount) {
newlist = true;
@@ -4471,13 +4484,20 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action,
}
}
+ if ((di = tv_dict_find(what, S_LEN("efm"))) != NULL) {
+ if (di->di_tv.v_type != VAR_STRING || di->di_tv.vval.v_string == NULL) {
+ return FAIL;
+ }
+ errorformat = di->di_tv.vval.v_string;
+ }
+
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);
}
- if (qf_init_ext(qi, qf_idx, NULL, NULL, &di->di_tv, p_efm,
+ if (qf_init_ext(qi, qf_idx, NULL, NULL, &di->di_tv, errorformat,
false, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0) {
retval = OK;
}
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index f1dc3d37be..36be956b92 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -2303,6 +2303,17 @@ func Xsetexpr_tests(cchar)
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)
+
+ " Adding entries using a custom efm
+ set efm&
+ call g:Xsetlist([], ' ', {'efm' : '%f#%l#%m',
+ \ 'lines' : ["F1#10#L10", "F2#20#L20"]})
+ call assert_equal(20, g:Xgetlist({'items':1}).items[1].lnum)
+ call g:Xsetlist([], 'a', {'efm' : '%f#%l#%m', 'lines' : ["F3:30:L30"]})
+ call assert_equal('F3:30:L30', g:Xgetlist({'items':1}).items[2].text)
+ call assert_equal(20, g:Xgetlist({'items':1}).items[1].lnum)
+ call assert_equal(-1, g:Xsetlist([], 'a', {'efm' : [],
+ \ 'lines' : ['F1:10:L10']}))
endfunc
func Test_setexpr()
@@ -2519,6 +2530,17 @@ func XgetListFromLines(cchar)
call assert_equal([], g:Xgetlist({'lines' : []}).items)
call assert_equal([], g:Xgetlist({'lines' : [10, 20]}).items)
+ " Parse text using a custom efm
+ set efm&
+ let l = g:Xgetlist({'lines':['File3#30#Line30'], 'efm' : '%f#%l#%m'}).items
+ call assert_equal('Line30', l[0].text)
+ let l = g:Xgetlist({'lines':['File3:30:Line30'], 'efm' : '%f-%l-%m'}).items
+ call assert_equal('File3:30:Line30', l[0].text)
+ let l = g:Xgetlist({'lines':['File3:30:Line30'], 'efm' : [1,2]})
+ call assert_equal({}, l)
+ call assert_fails("call g:Xgetlist({'lines':['abc'], 'efm':'%2'})", 'E376:')
+ call assert_fails("call g:Xgetlist({'lines':['abc'], 'efm':''})", 'E378:')
+
" Make sure that the quickfix stack is not modified
call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
endfunc