diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-09-15 22:43:07 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-09-15 22:43:07 +0200 |
commit | fc2b270cfd36230166df486aae4d96d9d1f32755 (patch) | |
tree | 5ac8fa6f9e68be4fcbe41fc046f1e0734a0a649a /src/quickfix.c | |
parent | b5e79ef5a9e85f5bb70eb4cc6e12cbeec2a820ca (diff) | |
download | vim-git-fc2b270cfd36230166df486aae4d96d9d1f32755.tar.gz |
patch 8.0.1112: can't get size or current index from quickfix listv8.0.1112
Problem: Can't get size or current index from quickfix list.
Solution: Add "idx" and "size" options. (Yegappan Lakshmanan)
Diffstat (limited to 'src/quickfix.c')
-rw-r--r-- | src/quickfix.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/quickfix.c b/src/quickfix.c index 5ff4091d5..39eb5b63a 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -2212,8 +2212,7 @@ qf_jump(qf_info_T *qi, old_qf_ptr = qf_ptr; qf_index = qi->qf_lists[qi->qf_curlist].qf_index; old_qf_index = qf_index; - if (dir == FORWARD || dir == FORWARD_FILE || - dir == BACKWARD || dir == BACKWARD_FILE) /* next/prev valid entry */ + if (dir != 0) /* next/prev valid entry */ { qf_ptr = get_nth_valid_entry(qi, errornr, qf_ptr, &qf_index, dir); if (qf_ptr == NULL) @@ -4726,6 +4725,8 @@ enum { QF_GETLIST_WINID = 0x8, QF_GETLIST_CONTEXT = 0x10, QF_GETLIST_ID = 0x20, + QF_GETLIST_IDX = 0x40, + QF_GETLIST_SIZE = 0x80, QF_GETLIST_ALL = 0xFF }; @@ -4882,6 +4883,12 @@ qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict) if (dict_find(what, (char_u *)"items", -1) != NULL) flags |= QF_GETLIST_ITEMS; + if (dict_find(what, (char_u *)"idx", -1) != NULL) + flags |= QF_GETLIST_IDX; + + if (dict_find(what, (char_u *)"size", -1) != NULL) + flags |= QF_GETLIST_SIZE; + if (flags & QF_GETLIST_TITLE) { char_u *t; @@ -4934,6 +4941,19 @@ qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict) status = dict_add_nr_str(retdict, "id", qi->qf_lists[qf_idx].qf_id, NULL); + if ((status == OK) && (flags & QF_GETLIST_IDX)) + { + int idx = qi->qf_lists[qf_idx].qf_index; + if (qi->qf_lists[qf_idx].qf_count == 0) + /* For empty lists, qf_index is set to 1 */ + idx = 0; + status = dict_add_nr_str(retdict, "idx", idx, NULL); + } + + if ((status == OK) && (flags & QF_GETLIST_SIZE)) + status = dict_add_nr_str(retdict, "size", + qi->qf_lists[qf_idx].qf_count, NULL); + return status; } |