Mercurial > vim
comparison src/quickfix.c @ 12465:805f7fd40e0d v8.0.1112
patch 8.0.1112: can't get size or current index from quickfix list
commit https://github.com/vim/vim/commit/fc2b270cfd36230166df486aae4d96d9d1f32755
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Sep 15 22:43:07 2017 +0200
patch 8.0.1112: can't get size or current index from quickfix list
Problem: Can't get size or current index from quickfix list.
Solution: Add "idx" and "size" options. (Yegappan Lakshmanan)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 15 Sep 2017 22:45:04 +0200 |
parents | 7a743053dfd6 |
children | 68d7bc045dbe |
comparison
equal
deleted
inserted
replaced
12464:ab743b602cd7 | 12465:805f7fd40e0d |
---|---|
2210 | 2210 |
2211 qf_ptr = qi->qf_lists[qi->qf_curlist].qf_ptr; | 2211 qf_ptr = qi->qf_lists[qi->qf_curlist].qf_ptr; |
2212 old_qf_ptr = qf_ptr; | 2212 old_qf_ptr = qf_ptr; |
2213 qf_index = qi->qf_lists[qi->qf_curlist].qf_index; | 2213 qf_index = qi->qf_lists[qi->qf_curlist].qf_index; |
2214 old_qf_index = qf_index; | 2214 old_qf_index = qf_index; |
2215 if (dir == FORWARD || dir == FORWARD_FILE || | 2215 if (dir != 0) /* next/prev valid entry */ |
2216 dir == BACKWARD || dir == BACKWARD_FILE) /* next/prev valid entry */ | |
2217 { | 2216 { |
2218 qf_ptr = get_nth_valid_entry(qi, errornr, qf_ptr, &qf_index, dir); | 2217 qf_ptr = get_nth_valid_entry(qi, errornr, qf_ptr, &qf_index, dir); |
2219 if (qf_ptr == NULL) | 2218 if (qf_ptr == NULL) |
2220 { | 2219 { |
2221 qf_ptr = old_qf_ptr; | 2220 qf_ptr = old_qf_ptr; |
4724 QF_GETLIST_ITEMS = 0x2, | 4723 QF_GETLIST_ITEMS = 0x2, |
4725 QF_GETLIST_NR = 0x4, | 4724 QF_GETLIST_NR = 0x4, |
4726 QF_GETLIST_WINID = 0x8, | 4725 QF_GETLIST_WINID = 0x8, |
4727 QF_GETLIST_CONTEXT = 0x10, | 4726 QF_GETLIST_CONTEXT = 0x10, |
4728 QF_GETLIST_ID = 0x20, | 4727 QF_GETLIST_ID = 0x20, |
4728 QF_GETLIST_IDX = 0x40, | |
4729 QF_GETLIST_SIZE = 0x80, | |
4729 QF_GETLIST_ALL = 0xFF | 4730 QF_GETLIST_ALL = 0xFF |
4730 }; | 4731 }; |
4731 | 4732 |
4732 /* | 4733 /* |
4733 * Parse text from 'di' and return the quickfix list items | 4734 * Parse text from 'di' and return the quickfix list items |
4880 flags |= QF_GETLIST_CONTEXT; | 4881 flags |= QF_GETLIST_CONTEXT; |
4881 | 4882 |
4882 if (dict_find(what, (char_u *)"items", -1) != NULL) | 4883 if (dict_find(what, (char_u *)"items", -1) != NULL) |
4883 flags |= QF_GETLIST_ITEMS; | 4884 flags |= QF_GETLIST_ITEMS; |
4884 | 4885 |
4886 if (dict_find(what, (char_u *)"idx", -1) != NULL) | |
4887 flags |= QF_GETLIST_IDX; | |
4888 | |
4889 if (dict_find(what, (char_u *)"size", -1) != NULL) | |
4890 flags |= QF_GETLIST_SIZE; | |
4891 | |
4885 if (flags & QF_GETLIST_TITLE) | 4892 if (flags & QF_GETLIST_TITLE) |
4886 { | 4893 { |
4887 char_u *t; | 4894 char_u *t; |
4888 t = qi->qf_lists[qf_idx].qf_title; | 4895 t = qi->qf_lists[qf_idx].qf_title; |
4889 if (t == NULL) | 4896 if (t == NULL) |
4931 } | 4938 } |
4932 | 4939 |
4933 if ((status == OK) && (flags & QF_GETLIST_ID)) | 4940 if ((status == OK) && (flags & QF_GETLIST_ID)) |
4934 status = dict_add_nr_str(retdict, "id", qi->qf_lists[qf_idx].qf_id, | 4941 status = dict_add_nr_str(retdict, "id", qi->qf_lists[qf_idx].qf_id, |
4935 NULL); | 4942 NULL); |
4943 | |
4944 if ((status == OK) && (flags & QF_GETLIST_IDX)) | |
4945 { | |
4946 int idx = qi->qf_lists[qf_idx].qf_index; | |
4947 if (qi->qf_lists[qf_idx].qf_count == 0) | |
4948 /* For empty lists, qf_index is set to 1 */ | |
4949 idx = 0; | |
4950 status = dict_add_nr_str(retdict, "idx", idx, NULL); | |
4951 } | |
4952 | |
4953 if ((status == OK) && (flags & QF_GETLIST_SIZE)) | |
4954 status = dict_add_nr_str(retdict, "size", | |
4955 qi->qf_lists[qf_idx].qf_count, NULL); | |
4936 | 4956 |
4937 return status; | 4957 return status; |
4938 } | 4958 } |
4939 | 4959 |
4940 /* | 4960 /* |