Mercurial > vim
comparison src/quickfix.c @ 14915:f508bb2fb808 v8.1.0469
patch 8.1.0469: too often indexing in qf_lists[]
commit https://github.com/vim/vim/commit/108e7b422b7b59153dd5af1fb75e83fa36ff3db4
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 11 17:39:12 2018 +0200
patch 8.1.0469: too often indexing in qf_lists[]
Problem: Too often indexing in qf_lists[].
Solution: Use a qf_list_T pointer. (Yegappan Lakshmanan)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 11 Oct 2018 17:45:07 +0200 |
parents | e35d98651e56 |
children | 69d2749a6a2f |
comparison
equal
deleted
inserted
replaced
14914:68eba5f83aed | 14915:f508bb2fb808 |
---|---|
1727 EMSG(_(e_readerrf)); | 1727 EMSG(_(e_readerrf)); |
1728 error2: | 1728 error2: |
1729 if (!adding) | 1729 if (!adding) |
1730 { | 1730 { |
1731 // Error when creating a new list. Free the new list | 1731 // Error when creating a new list. Free the new list |
1732 qf_free(&qi->qf_lists[qi->qf_curlist]); | 1732 qf_free(qfl); |
1733 qi->qf_listcount--; | 1733 qi->qf_listcount--; |
1734 if (qi->qf_curlist > 0) | 1734 if (qi->qf_curlist > 0) |
1735 --qi->qf_curlist; | 1735 --qi->qf_curlist; |
1736 } | 1736 } |
1737 qf_init_end: | 1737 qf_init_end: |
1810 */ | 1810 */ |
1811 static void | 1811 static void |
1812 qf_new_list(qf_info_T *qi, char_u *qf_title) | 1812 qf_new_list(qf_info_T *qi, char_u *qf_title) |
1813 { | 1813 { |
1814 int i; | 1814 int i; |
1815 qf_list_T *qfl; | |
1815 | 1816 |
1816 // If the current entry is not the last entry, delete entries beyond | 1817 // If the current entry is not the last entry, delete entries beyond |
1817 // the current entry. This makes it possible to browse in a tree-like | 1818 // the current entry. This makes it possible to browse in a tree-like |
1818 // way with ":grep'. | 1819 // way with ":grep'. |
1819 while (qi->qf_listcount > qi->qf_curlist + 1) | 1820 while (qi->qf_listcount > qi->qf_curlist + 1) |
1828 qi->qf_lists[i - 1] = qi->qf_lists[i]; | 1829 qi->qf_lists[i - 1] = qi->qf_lists[i]; |
1829 qi->qf_curlist = LISTCOUNT - 1; | 1830 qi->qf_curlist = LISTCOUNT - 1; |
1830 } | 1831 } |
1831 else | 1832 else |
1832 qi->qf_curlist = qi->qf_listcount++; | 1833 qi->qf_curlist = qi->qf_listcount++; |
1833 vim_memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T))); | 1834 qfl = &qi->qf_lists[qi->qf_curlist]; |
1834 qf_store_title(&qi->qf_lists[qi->qf_curlist], qf_title); | 1835 vim_memset(qfl, 0, (size_t)(sizeof(qf_list_T))); |
1835 qi->qf_lists[qi->qf_curlist].qf_id = ++last_qf_id; | 1836 qf_store_title(qfl, qf_title); |
1837 qfl->qf_id = ++last_qf_id; | |
1836 } | 1838 } |
1837 | 1839 |
1838 /* | 1840 /* |
1839 * Free a location list stack | 1841 * Free a location list stack |
1840 */ | 1842 */ |
2147 * Also sets the b_has_qf_entry flag. | 2149 * Also sets the b_has_qf_entry flag. |
2148 */ | 2150 */ |
2149 static int | 2151 static int |
2150 qf_get_fnum(qf_info_T *qi, int qf_idx, char_u *directory, char_u *fname) | 2152 qf_get_fnum(qf_info_T *qi, int qf_idx, char_u *directory, char_u *fname) |
2151 { | 2153 { |
2154 qf_list_T *qfl = &qi->qf_lists[qf_idx]; | |
2152 char_u *ptr = NULL; | 2155 char_u *ptr = NULL; |
2153 buf_T *buf; | 2156 buf_T *buf; |
2154 char_u *bufname; | 2157 char_u *bufname; |
2155 | 2158 |
2156 if (fname == NULL || *fname == NUL) // no file name | 2159 if (fname == NULL || *fname == NUL) // no file name |
2172 // "leaving directory"-messages we might have missed a | 2175 // "leaving directory"-messages we might have missed a |
2173 // directory change. | 2176 // directory change. |
2174 if (mch_getperm(ptr) < 0) | 2177 if (mch_getperm(ptr) < 0) |
2175 { | 2178 { |
2176 vim_free(ptr); | 2179 vim_free(ptr); |
2177 directory = qf_guess_filepath(&qi->qf_lists[qf_idx], fname); | 2180 directory = qf_guess_filepath(qfl, fname); |
2178 if (directory) | 2181 if (directory) |
2179 ptr = concat_fnames(directory, fname, TRUE); | 2182 ptr = concat_fnames(directory, fname, TRUE); |
2180 else | 2183 else |
2181 ptr = vim_strsave(fname); | 2184 ptr = vim_strsave(fname); |
2182 } | 2185 } |
3755 */ | 3758 */ |
3756 void | 3759 void |
3757 ex_cwindow(exarg_T *eap) | 3760 ex_cwindow(exarg_T *eap) |
3758 { | 3761 { |
3759 qf_info_T *qi = &ql_info; | 3762 qf_info_T *qi = &ql_info; |
3763 qf_list_T *qfl; | |
3760 win_T *win; | 3764 win_T *win; |
3761 | 3765 |
3762 if (is_loclist_cmd(eap->cmdidx)) | 3766 if (is_loclist_cmd(eap->cmdidx)) |
3763 { | 3767 { |
3764 qi = GET_LOC_LIST(curwin); | 3768 qi = GET_LOC_LIST(curwin); |
3765 if (qi == NULL) | 3769 if (qi == NULL) |
3766 return; | 3770 return; |
3767 } | 3771 } |
3772 | |
3773 qfl = &qi->qf_lists[qi->qf_curlist]; | |
3768 | 3774 |
3769 // Look for an existing quickfix window. | 3775 // Look for an existing quickfix window. |
3770 win = qf_find_win(qi); | 3776 win = qf_find_win(qi); |
3771 | 3777 |
3772 // If a quickfix window is open but we have no errors to display, | 3778 // If a quickfix window is open but we have no errors to display, |
3773 // close the window. If a quickfix window is not open, then open | 3779 // close the window. If a quickfix window is not open, then open |
3774 // it if we have errors; otherwise, leave it closed. | 3780 // it if we have errors; otherwise, leave it closed. |
3775 if (qf_stack_empty(qi) | 3781 if (qf_stack_empty(qi) |
3776 || qi->qf_lists[qi->qf_curlist].qf_nonevalid | 3782 || qfl->qf_nonevalid |
3777 || qf_list_empty(qi, qi->qf_curlist)) | 3783 || qf_list_empty(qi, qi->qf_curlist)) |
3778 { | 3784 { |
3779 if (win != NULL) | 3785 if (win != NULL) |
3780 ex_cclose(eap); | 3786 ex_cclose(eap); |
3781 } | 3787 } |
3928 */ | 3934 */ |
3929 void | 3935 void |
3930 ex_copen(exarg_T *eap) | 3936 ex_copen(exarg_T *eap) |
3931 { | 3937 { |
3932 qf_info_T *qi = &ql_info; | 3938 qf_info_T *qi = &ql_info; |
3939 qf_list_T *qfl; | |
3933 int height; | 3940 int height; |
3934 int status = FAIL; | 3941 int status = FAIL; |
3935 | 3942 |
3936 if (is_loclist_cmd(eap->cmdidx)) | 3943 if (is_loclist_cmd(eap->cmdidx)) |
3937 { | 3944 { |
3959 cmdmod.split & WSP_VERT); | 3966 cmdmod.split & WSP_VERT); |
3960 if (status == FAIL) | 3967 if (status == FAIL) |
3961 if (qf_open_new_cwindow(qi, height) == FAIL) | 3968 if (qf_open_new_cwindow(qi, height) == FAIL) |
3962 return; | 3969 return; |
3963 | 3970 |
3964 qf_set_title_var(&qi->qf_lists[qi->qf_curlist]); | 3971 qfl = &qi->qf_lists[qi->qf_curlist]; |
3972 qf_set_title_var(qfl); | |
3965 | 3973 |
3966 // Fill the buffer with the quickfix list. | 3974 // Fill the buffer with the quickfix list. |
3967 qf_fill_buffer(qi, curbuf, NULL); | 3975 qf_fill_buffer(qi, curbuf, NULL); |
3968 | 3976 |
3969 curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index; | 3977 curwin->w_cursor.lnum = qfl->qf_index; |
3970 curwin->w_cursor.col = 0; | 3978 curwin->w_cursor.col = 0; |
3971 check_cursor(); | 3979 check_cursor(); |
3972 update_topline(); // scroll to show the line | 3980 update_topline(); // scroll to show the line |
3973 } | 3981 } |
3974 | 3982 |
4280 } | 4288 } |
4281 | 4289 |
4282 // Check if there is anything to display | 4290 // Check if there is anything to display |
4283 if (!qf_stack_empty(qi)) | 4291 if (!qf_stack_empty(qi)) |
4284 { | 4292 { |
4285 char_u dirname[MAXPATHL]; | 4293 qf_list_T *qfl = &qi->qf_lists[qi->qf_curlist]; |
4294 char_u dirname[MAXPATHL]; | |
4286 | 4295 |
4287 *dirname = NUL; | 4296 *dirname = NUL; |
4288 | 4297 |
4289 // Add one line for each error | 4298 // Add one line for each error |
4290 if (old_last == NULL) | 4299 if (old_last == NULL) |
4291 { | 4300 { |
4292 qfp = qi->qf_lists[qi->qf_curlist].qf_start; | 4301 qfp = qfl->qf_start; |
4293 lnum = 0; | 4302 lnum = 0; |
4294 } | 4303 } |
4295 else | 4304 else |
4296 { | 4305 { |
4297 qfp = old_last->qf_next; | 4306 qfp = old_last->qf_next; |
4298 lnum = buf->b_ml.ml_line_count; | 4307 lnum = buf->b_ml.ml_line_count; |
4299 } | 4308 } |
4300 while (lnum < qi->qf_lists[qi->qf_curlist].qf_count) | 4309 while (lnum < qfl->qf_count) |
4301 { | 4310 { |
4302 if (qf_buf_add_line(buf, lnum, qfp, dirname) == FAIL) | 4311 if (qf_buf_add_line(buf, lnum, qfp, dirname) == FAIL) |
4303 break; | 4312 break; |
4304 | 4313 |
4305 ++lnum; | 4314 ++lnum; |
4343 | 4352 |
4344 /* | 4353 /* |
4345 * For every change made to the quickfix list, update the changed tick. | 4354 * For every change made to the quickfix list, update the changed tick. |
4346 */ | 4355 */ |
4347 static void | 4356 static void |
4348 qf_list_changed(qf_info_T *qi, int qf_idx) | 4357 qf_list_changed(qf_list_T *qfl) |
4349 { | 4358 { |
4350 qi->qf_lists[qf_idx].qf_changedtick++; | 4359 qfl->qf_changedtick++; |
4351 } | 4360 } |
4352 | 4361 |
4353 /* | 4362 /* |
4354 * Return the quickfix/location list number with the given identifier. | 4363 * Return the quickfix/location list number with the given identifier. |
4355 * Returns -1 if list is not found. | 4364 * Returns -1 if list is not found. |
4593 qi = GET_LOC_LIST(wp); | 4602 qi = GET_LOC_LIST(wp); |
4594 if (qi == NULL) | 4603 if (qi == NULL) |
4595 goto cleanup; | 4604 goto cleanup; |
4596 } | 4605 } |
4597 if (res >= 0) | 4606 if (res >= 0) |
4598 qf_list_changed(qi, qi->qf_curlist); | 4607 qf_list_changed(&qi->qf_lists[qi->qf_curlist]); |
4599 | 4608 |
4600 // Remember the current quickfix list identifier, so that we can | 4609 // Remember the current quickfix list identifier, so that we can |
4601 // check for autocommands changing the current quickfix list. | 4610 // check for autocommands changing the current quickfix list. |
4602 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; | 4611 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; |
4603 if (au_name != NULL) | 4612 if (au_name != NULL) |
4618 */ | 4627 */ |
4619 int | 4628 int |
4620 qf_get_size(exarg_T *eap) | 4629 qf_get_size(exarg_T *eap) |
4621 { | 4630 { |
4622 qf_info_T *qi = &ql_info; | 4631 qf_info_T *qi = &ql_info; |
4632 qf_list_T *qfl; | |
4623 qfline_T *qfp; | 4633 qfline_T *qfp; |
4624 int i, sz = 0; | 4634 int i, sz = 0; |
4625 int prev_fnum = 0; | 4635 int prev_fnum = 0; |
4626 | 4636 |
4627 if (is_loclist_cmd(eap->cmdidx)) | 4637 if (is_loclist_cmd(eap->cmdidx)) |
4630 qi = GET_LOC_LIST(curwin); | 4640 qi = GET_LOC_LIST(curwin); |
4631 if (qi == NULL) | 4641 if (qi == NULL) |
4632 return 0; | 4642 return 0; |
4633 } | 4643 } |
4634 | 4644 |
4635 for (i = 0, qfp = qi->qf_lists[qi->qf_curlist].qf_start; | 4645 qfl = &qi->qf_lists[qi->qf_curlist]; |
4636 i < qi->qf_lists[qi->qf_curlist].qf_count && qfp != NULL; | 4646 for (i = 0, qfp = qfl->qf_start; i < qfl->qf_count && qfp != NULL; |
4637 ++i, qfp = qfp->qf_next) | 4647 ++i, qfp = qfp->qf_next) |
4638 { | 4648 { |
4639 if (qfp->qf_valid) | 4649 if (qfp->qf_valid) |
4640 { | 4650 { |
4641 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo) | 4651 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo) |
4933 qi = GET_LOC_LIST(wp); | 4943 qi = GET_LOC_LIST(wp); |
4934 if (qi == NULL) | 4944 if (qi == NULL) |
4935 return; | 4945 return; |
4936 } | 4946 } |
4937 if (res >= 0) | 4947 if (res >= 0) |
4938 qf_list_changed(qi, qi->qf_curlist); | 4948 qf_list_changed(&qi->qf_lists[qi->qf_curlist]); |
4939 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; | 4949 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; |
4940 if (au_name != NULL) | 4950 if (au_name != NULL) |
4941 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); | 4951 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); |
4942 | 4952 |
4943 // Jump to the first error for a new list and if autocmds didn't | 4953 // Jump to the first error for a new list and if autocmds didn't |
5202 char_u *title; | 5212 char_u *title; |
5203 char_u *s; | 5213 char_u *s; |
5204 char_u *p; | 5214 char_u *p; |
5205 int fi; | 5215 int fi; |
5206 qf_info_T *qi = &ql_info; | 5216 qf_info_T *qi = &ql_info; |
5217 qf_list_T *qfl; | |
5207 int_u save_qfid; | 5218 int_u save_qfid; |
5208 win_T *wp = NULL; | 5219 win_T *wp = NULL; |
5209 buf_T *buf; | 5220 buf_T *buf; |
5210 int duplicate_name = FALSE; | 5221 int duplicate_name = FALSE; |
5211 int using_dummy; | 5222 int using_dummy; |
5408 } | 5419 } |
5409 } | 5420 } |
5410 | 5421 |
5411 FreeWild(fcount, fnames); | 5422 FreeWild(fcount, fnames); |
5412 | 5423 |
5413 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; | 5424 qfl = &qi->qf_lists[qi->qf_curlist]; |
5414 qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start; | 5425 qfl->qf_nonevalid = FALSE; |
5415 qi->qf_lists[qi->qf_curlist].qf_index = 1; | 5426 qfl->qf_ptr = qfl->qf_start; |
5416 qf_list_changed(qi, qi->qf_curlist); | 5427 qfl->qf_index = 1; |
5428 qf_list_changed(qfl); | |
5417 | 5429 |
5418 qf_update_buffer(qi, NULL); | 5430 qf_update_buffer(qi, NULL); |
5419 | 5431 |
5420 if (au_name != NULL) | 5432 if (au_name != NULL) |
5421 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, | 5433 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
5913 status = dict_add_number(retdict, "idx", 0); | 5925 status = dict_add_number(retdict, "idx", 0); |
5914 if ((status == OK) && (flags & QF_GETLIST_SIZE)) | 5926 if ((status == OK) && (flags & QF_GETLIST_SIZE)) |
5915 status = dict_add_number(retdict, "size", 0); | 5927 status = dict_add_number(retdict, "size", 0); |
5916 if ((status == OK) && (flags & QF_GETLIST_TICK)) | 5928 if ((status == OK) && (flags & QF_GETLIST_TICK)) |
5917 status = dict_add_number(retdict, "changedtick", 0); | 5929 status = dict_add_number(retdict, "changedtick", 0); |
5918 if ((status == OK) && (qi != &ql_info) && (flags & QF_GETLIST_FILEWINID)) | 5930 if ((status == OK) && IS_LL_STACK(qi) && (flags & QF_GETLIST_FILEWINID)) |
5919 status = dict_add_number(retdict, "filewinid", 0); | 5931 status = dict_add_number(retdict, "filewinid", 0); |
5920 | 5932 |
5921 return status; | 5933 return status; |
5922 } | 5934 } |
5923 | 5935 |
5924 /* | 5936 /* |
5925 * Return the quickfix list title as 'title' in retdict | 5937 * Return the quickfix list title as 'title' in retdict |
5926 */ | 5938 */ |
5927 static int | 5939 static int |
5928 qf_getprop_title(qf_info_T *qi, int qf_idx, dict_T *retdict) | 5940 qf_getprop_title(qf_list_T *qfl, dict_T *retdict) |
5929 { | 5941 { |
5930 return dict_add_string(retdict, "title", qi->qf_lists[qf_idx].qf_title); | 5942 return dict_add_string(retdict, "title", qfl->qf_title); |
5931 } | 5943 } |
5932 | 5944 |
5933 /* | 5945 /* |
5934 * Returns the identifier of the window used to display files from a location | 5946 * Returns the identifier of the window used to display files from a location |
5935 * list. If there is no associated window, then returns 0. Useful only when | 5947 * list. If there is no associated window, then returns 0. Useful only when |
5971 | 5983 |
5972 /* | 5984 /* |
5973 * Return the quickfix list context (if any) as 'context' in retdict. | 5985 * Return the quickfix list context (if any) as 'context' in retdict. |
5974 */ | 5986 */ |
5975 static int | 5987 static int |
5976 qf_getprop_ctx(qf_info_T *qi, int qf_idx, dict_T *retdict) | 5988 qf_getprop_ctx(qf_list_T *qfl, dict_T *retdict) |
5977 { | 5989 { |
5978 int status; | 5990 int status; |
5979 dictitem_T *di; | 5991 dictitem_T *di; |
5980 | 5992 |
5981 if (qi->qf_lists[qf_idx].qf_ctx != NULL) | 5993 if (qfl->qf_ctx != NULL) |
5982 { | 5994 { |
5983 di = dictitem_alloc((char_u *)"context"); | 5995 di = dictitem_alloc((char_u *)"context"); |
5984 if (di != NULL) | 5996 if (di != NULL) |
5985 { | 5997 { |
5986 copy_tv(qi->qf_lists[qf_idx].qf_ctx, &di->di_tv); | 5998 copy_tv(qfl->qf_ctx, &di->di_tv); |
5987 status = dict_add(retdict, di); | 5999 status = dict_add(retdict, di); |
5988 if (status == FAIL) | 6000 if (status == FAIL) |
5989 dictitem_free(di); | 6001 dictitem_free(di); |
5990 } | 6002 } |
5991 else | 6003 else |
5996 | 6008 |
5997 return status; | 6009 return status; |
5998 } | 6010 } |
5999 | 6011 |
6000 /* | 6012 /* |
6001 * Return the quickfix list index as 'idx' in retdict | 6013 * Return the current quickfix list index as 'idx' in retdict |
6002 */ | 6014 */ |
6003 static int | 6015 static int |
6004 qf_getprop_idx(qf_info_T *qi, int qf_idx, dict_T *retdict) | 6016 qf_getprop_idx(qf_info_T *qi, int qf_idx, dict_T *retdict) |
6005 { | 6017 { |
6006 int idx = qi->qf_lists[qf_idx].qf_index; | 6018 int curidx = qi->qf_lists[qf_idx].qf_index; |
6007 if (qf_list_empty(qi, qf_idx)) | 6019 if (qf_list_empty(qi, qf_idx)) |
6008 // For empty lists, qf_index is set to 1 | 6020 // For empty lists, current index is set to 0 |
6009 idx = 0; | 6021 curidx = 0; |
6010 return dict_add_number(retdict, "idx", idx); | 6022 return dict_add_number(retdict, "idx", curidx); |
6011 } | 6023 } |
6012 | 6024 |
6013 /* | 6025 /* |
6014 * Return quickfix/location list details (title) as a | 6026 * Return quickfix/location list details (title) as a |
6015 * dictionary. 'what' contains the details to return. If 'list_idx' is -1, | 6027 * dictionary. 'what' contains the details to return. If 'list_idx' is -1, |
6019 qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict) | 6031 qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict) |
6020 { | 6032 { |
6021 qf_info_T *qi = &ql_info; | 6033 qf_info_T *qi = &ql_info; |
6022 qf_list_T *qfl; | 6034 qf_list_T *qfl; |
6023 int status = OK; | 6035 int status = OK; |
6024 int qf_idx; | 6036 int qf_idx = INVALID_QFIDX; |
6025 dictitem_T *di; | 6037 dictitem_T *di; |
6026 int flags = QF_GETLIST_NONE; | 6038 int flags = QF_GETLIST_NONE; |
6027 | 6039 |
6028 if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL) | 6040 if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL) |
6029 return qf_get_list_from_lines(what, di, retdict); | 6041 return qf_get_list_from_lines(what, di, retdict); |
6041 return qf_getprop_defaults(qi, flags, retdict); | 6053 return qf_getprop_defaults(qi, flags, retdict); |
6042 | 6054 |
6043 qfl = &qi->qf_lists[qf_idx]; | 6055 qfl = &qi->qf_lists[qf_idx]; |
6044 | 6056 |
6045 if (flags & QF_GETLIST_TITLE) | 6057 if (flags & QF_GETLIST_TITLE) |
6046 status = qf_getprop_title(qi, qf_idx, retdict); | 6058 status = qf_getprop_title(qfl, retdict); |
6047 if ((status == OK) && (flags & QF_GETLIST_NR)) | 6059 if ((status == OK) && (flags & QF_GETLIST_NR)) |
6048 status = dict_add_number(retdict, "nr", qf_idx + 1); | 6060 status = dict_add_number(retdict, "nr", qf_idx + 1); |
6049 if ((status == OK) && (flags & QF_GETLIST_WINID)) | 6061 if ((status == OK) && (flags & QF_GETLIST_WINID)) |
6050 status = dict_add_number(retdict, "winid", qf_winid(qi)); | 6062 status = dict_add_number(retdict, "winid", qf_winid(qi)); |
6051 if ((status == OK) && (flags & QF_GETLIST_ITEMS)) | 6063 if ((status == OK) && (flags & QF_GETLIST_ITEMS)) |
6052 status = qf_getprop_items(qi, qf_idx, retdict); | 6064 status = qf_getprop_items(qi, qf_idx, retdict); |
6053 if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) | 6065 if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) |
6054 status = qf_getprop_ctx(qi, qf_idx, retdict); | 6066 status = qf_getprop_ctx(qfl, retdict); |
6055 if ((status == OK) && (flags & QF_GETLIST_ID)) | 6067 if ((status == OK) && (flags & QF_GETLIST_ID)) |
6056 status = dict_add_number(retdict, "id", qfl->qf_id); | 6068 status = dict_add_number(retdict, "id", qfl->qf_id); |
6057 if ((status == OK) && (flags & QF_GETLIST_IDX)) | 6069 if ((status == OK) && (flags & QF_GETLIST_IDX)) |
6058 status = qf_getprop_idx(qi, qf_idx, retdict); | 6070 status = qf_getprop_idx(qi, qf_idx, retdict); |
6059 if ((status == OK) && (flags & QF_GETLIST_SIZE)) | 6071 if ((status == OK) && (flags & QF_GETLIST_SIZE)) |
6275 * Set the quickfix list title. | 6287 * Set the quickfix list title. |
6276 */ | 6288 */ |
6277 static int | 6289 static int |
6278 qf_setprop_title(qf_info_T *qi, int qf_idx, dict_T *what, dictitem_T *di) | 6290 qf_setprop_title(qf_info_T *qi, int qf_idx, dict_T *what, dictitem_T *di) |
6279 { | 6291 { |
6292 qf_list_T *qfl = &qi->qf_lists[qf_idx]; | |
6293 | |
6280 if (di->di_tv.v_type != VAR_STRING) | 6294 if (di->di_tv.v_type != VAR_STRING) |
6281 return FAIL; | 6295 return FAIL; |
6282 | 6296 |
6283 vim_free(qi->qf_lists[qf_idx].qf_title); | 6297 vim_free(qfl->qf_title); |
6284 qi->qf_lists[qf_idx].qf_title = | 6298 qfl->qf_title = get_dict_string(what, (char_u *)"title", TRUE); |
6285 get_dict_string(what, (char_u *)"title", TRUE); | |
6286 if (qf_idx == qi->qf_curlist) | 6299 if (qf_idx == qi->qf_curlist) |
6287 qf_update_win_titlevar(qi); | 6300 qf_update_win_titlevar(qi); |
6288 | 6301 |
6289 return OK; | 6302 return OK; |
6290 } | 6303 } |
6373 { | 6386 { |
6374 dictitem_T *di; | 6387 dictitem_T *di; |
6375 int retval = FAIL; | 6388 int retval = FAIL; |
6376 int qf_idx; | 6389 int qf_idx; |
6377 int newlist = FALSE; | 6390 int newlist = FALSE; |
6391 qf_list_T *qfl; | |
6378 | 6392 |
6379 if (action == ' ' || qf_stack_empty(qi)) | 6393 if (action == ' ' || qf_stack_empty(qi)) |
6380 newlist = TRUE; | 6394 newlist = TRUE; |
6381 | 6395 |
6382 qf_idx = qf_setprop_get_qfidx(qi, what, action, &newlist); | 6396 qf_idx = qf_setprop_get_qfidx(qi, what, action, &newlist); |
6388 qi->qf_curlist = qf_idx; | 6402 qi->qf_curlist = qf_idx; |
6389 qf_new_list(qi, title); | 6403 qf_new_list(qi, title); |
6390 qf_idx = qi->qf_curlist; | 6404 qf_idx = qi->qf_curlist; |
6391 } | 6405 } |
6392 | 6406 |
6407 qfl = &qi->qf_lists[qf_idx]; | |
6393 if ((di = dict_find(what, (char_u *)"title", -1)) != NULL) | 6408 if ((di = dict_find(what, (char_u *)"title", -1)) != NULL) |
6394 retval = qf_setprop_title(qi, qf_idx, what, di); | 6409 retval = qf_setprop_title(qi, qf_idx, what, di); |
6395 if ((di = dict_find(what, (char_u *)"items", -1)) != NULL) | 6410 if ((di = dict_find(what, (char_u *)"items", -1)) != NULL) |
6396 retval = qf_setprop_items(qi, qf_idx, di, action); | 6411 retval = qf_setprop_items(qi, qf_idx, di, action); |
6397 if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL) | 6412 if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL) |
6398 retval = qf_setprop_items_from_lines(qi, qf_idx, what, di, action); | 6413 retval = qf_setprop_items_from_lines(qi, qf_idx, what, di, action); |
6399 if ((di = dict_find(what, (char_u *)"context", -1)) != NULL) | 6414 if ((di = dict_find(what, (char_u *)"context", -1)) != NULL) |
6400 retval = qf_setprop_context(&qi->qf_lists[qf_idx], di); | 6415 retval = qf_setprop_context(qfl, di); |
6401 | 6416 |
6402 if (retval == OK) | 6417 if (retval == OK) |
6403 qf_list_changed(qi, qf_idx); | 6418 qf_list_changed(qfl); |
6404 | 6419 |
6405 return retval; | 6420 return retval; |
6406 } | 6421 } |
6407 | 6422 |
6408 /* | 6423 /* |
6409 * Find the non-location list window with the specified location list in the | 6424 * Find the non-location list window with the specified location list stack in |
6410 * current tabpage. | 6425 * the current tabpage. |
6411 */ | 6426 */ |
6412 static win_T * | 6427 static win_T * |
6413 find_win_with_ll(qf_info_T *qi) | 6428 find_win_with_ll(qf_info_T *qi) |
6414 { | 6429 { |
6415 win_T *wp = NULL; | 6430 win_T *wp = NULL; |
6506 retval = qf_set_properties(qi, what, action, title); | 6521 retval = qf_set_properties(qi, what, action, title); |
6507 else | 6522 else |
6508 { | 6523 { |
6509 retval = qf_add_entries(qi, qi->qf_curlist, list, title, action); | 6524 retval = qf_add_entries(qi, qi->qf_curlist, list, title, action); |
6510 if (retval == OK) | 6525 if (retval == OK) |
6511 qf_list_changed(qi, qi->qf_curlist); | 6526 qf_list_changed(&qi->qf_lists[qi->qf_curlist]); |
6512 } | 6527 } |
6513 | 6528 |
6514 return retval; | 6529 return retval; |
6515 } | 6530 } |
6516 | 6531 |
6652 (eap->cmdidx != CMD_caddbuffer | 6667 (eap->cmdidx != CMD_caddbuffer |
6653 && eap->cmdidx != CMD_laddbuffer), | 6668 && eap->cmdidx != CMD_laddbuffer), |
6654 eap->line1, eap->line2, | 6669 eap->line1, eap->line2, |
6655 qf_title, NULL); | 6670 qf_title, NULL); |
6656 if (res >= 0) | 6671 if (res >= 0) |
6657 qf_list_changed(qi, qi->qf_curlist); | 6672 qf_list_changed(&qi->qf_lists[qi->qf_curlist]); |
6658 | 6673 |
6659 // Remember the current quickfix list identifier, so that we can | 6674 // Remember the current quickfix list identifier, so that we can |
6660 // check for autocommands changing the current quickfix list. | 6675 // check for autocommands changing the current quickfix list. |
6661 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; | 6676 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; |
6662 if (au_name != NULL) | 6677 if (au_name != NULL) |
6735 (eap->cmdidx != CMD_caddexpr | 6750 (eap->cmdidx != CMD_caddexpr |
6736 && eap->cmdidx != CMD_laddexpr), | 6751 && eap->cmdidx != CMD_laddexpr), |
6737 (linenr_T)0, (linenr_T)0, | 6752 (linenr_T)0, (linenr_T)0, |
6738 qf_cmdtitle(*eap->cmdlinep), NULL); | 6753 qf_cmdtitle(*eap->cmdlinep), NULL); |
6739 if (res >= 0) | 6754 if (res >= 0) |
6740 qf_list_changed(qi, qi->qf_curlist); | 6755 qf_list_changed(&qi->qf_lists[qi->qf_curlist]); |
6741 | 6756 |
6742 // Remember the current quickfix list identifier, so that we can | 6757 // Remember the current quickfix list identifier, so that we can |
6743 // check for autocommands changing the current quickfix list. | 6758 // check for autocommands changing the current quickfix list. |
6744 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; | 6759 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; |
6745 if (au_name != NULL) | 6760 if (au_name != NULL) |
7011 #endif | 7026 #endif |
7012 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING); | 7027 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING); |
7013 regmatch.rm_ic = FALSE; | 7028 regmatch.rm_ic = FALSE; |
7014 if (regmatch.regprog != NULL) | 7029 if (regmatch.regprog != NULL) |
7015 { | 7030 { |
7031 qf_list_T *qfl; | |
7032 | |
7016 // create a new quickfix list | 7033 // create a new quickfix list |
7017 qf_new_list(qi, qf_cmdtitle(*eap->cmdlinep)); | 7034 qf_new_list(qi, qf_cmdtitle(*eap->cmdlinep)); |
7018 | 7035 |
7019 hgr_search_in_rtp(qi, ®match, lang); | 7036 hgr_search_in_rtp(qi, ®match, lang); |
7020 | 7037 |
7021 vim_regfree(regmatch.regprog); | 7038 vim_regfree(regmatch.regprog); |
7022 | 7039 |
7023 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE; | 7040 qfl = &qi->qf_lists[qi->qf_curlist]; |
7024 qi->qf_lists[qi->qf_curlist].qf_ptr = | 7041 qfl->qf_nonevalid = FALSE; |
7025 qi->qf_lists[qi->qf_curlist].qf_start; | 7042 qfl->qf_ptr = qfl->qf_start; |
7026 qi->qf_lists[qi->qf_curlist].qf_index = 1; | 7043 qfl->qf_index = 1; |
7044 qf_list_changed(qfl); | |
7045 qf_update_buffer(qi, NULL); | |
7027 } | 7046 } |
7028 | 7047 |
7029 if (p_cpo == empty_option) | 7048 if (p_cpo == empty_option) |
7030 p_cpo = save_cpo; | 7049 p_cpo = save_cpo; |
7031 else | 7050 else |
7032 // Darn, some plugin changed the value. | 7051 // Darn, some plugin changed the value. |
7033 free_string_option(save_cpo); | 7052 free_string_option(save_cpo); |
7034 | 7053 |
7035 qf_list_changed(qi, qi->qf_curlist); | |
7036 qf_update_buffer(qi, NULL); | |
7037 | |
7038 if (au_name != NULL) | 7054 if (au_name != NULL) |
7039 { | 7055 { |
7040 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, | 7056 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, |
7041 curbuf->b_fname, TRUE, curbuf); | 7057 curbuf->b_fname, TRUE, curbuf); |
7042 if (!new_qi && IS_LL_STACK(qi) && qf_find_buf(qi) == NULL) | 7058 if (!new_qi && IS_LL_STACK(qi) && qf_find_buf(qi) == NULL) |