Mercurial > vim
comparison src/quickfix.c @ 12427:fc3e2d5614dd v8.0.1093
patch 8.0.1093: various small quickfix issues
commit https://github.com/vim/vim/commit/b4d5fbabc99917a8069ba32a60c2d73d4f60e128
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 11 19:31:28 2017 +0200
patch 8.0.1093: various small quickfix issues
Problem: Various small quickfix issues.
Solution: Remove ":" prefix from title set by a user. Add the qf_id2nr().
function. Add a couple more tests. Update documentation.
(Yegappan Lakshmanan)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 11 Sep 2017 19:45:04 +0200 |
parents | 2779d593a706 |
children | 7a743053dfd6 |
comparison
equal
deleted
inserted
replaced
12426:510faba3f8e5 | 12427:fc3e2d5614dd |
---|---|
4689 | 4689 |
4690 return status; | 4690 return status; |
4691 } | 4691 } |
4692 | 4692 |
4693 /* | 4693 /* |
4694 * Return the quickfix/location list number with the given identifier. | |
4695 * Returns -1 if list is not found. | |
4696 */ | |
4697 static int | |
4698 qf_id2nr(qf_info_T *qi, int_u qfid) | |
4699 { | |
4700 int qf_idx; | |
4701 | |
4702 for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++) | |
4703 if (qi->qf_lists[qf_idx].qf_id == qfid) | |
4704 return qf_idx; | |
4705 return -1; | |
4706 } | |
4707 | |
4708 /* | |
4694 * Return quickfix/location list details (title) as a | 4709 * Return quickfix/location list details (title) as a |
4695 * dictionary. 'what' contains the details to return. If 'list_idx' is -1, | 4710 * dictionary. 'what' contains the details to return. If 'list_idx' is -1, |
4696 * then current list is used. Otherwise the specified list is used. | 4711 * then current list is used. Otherwise the specified list is used. |
4697 */ | 4712 */ |
4698 int | 4713 int |
4699 get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) | 4714 qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict) |
4700 { | 4715 { |
4701 qf_info_T *qi = &ql_info; | 4716 qf_info_T *qi = &ql_info; |
4702 int status = OK; | 4717 int status = OK; |
4703 int qf_idx; | 4718 int qf_idx; |
4704 dictitem_T *di; | 4719 dictitem_T *di; |
4750 if (di->di_tv.v_type == VAR_NUMBER) | 4765 if (di->di_tv.v_type == VAR_NUMBER) |
4751 { | 4766 { |
4752 /* For zero, use the current list or the list specifed by 'nr' */ | 4767 /* For zero, use the current list or the list specifed by 'nr' */ |
4753 if (di->di_tv.vval.v_number != 0) | 4768 if (di->di_tv.vval.v_number != 0) |
4754 { | 4769 { |
4755 for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++) | 4770 qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number); |
4756 { | 4771 if (qf_idx == -1) |
4757 if (qi->qf_lists[qf_idx].qf_id == di->di_tv.vval.v_number) | |
4758 break; | |
4759 } | |
4760 if (qf_idx == qi->qf_listcount) | |
4761 return FAIL; /* List not found */ | 4772 return FAIL; /* List not found */ |
4762 } | 4773 } |
4763 flags |= QF_GETLIST_ID; | 4774 flags |= QF_GETLIST_ID; |
4764 } | 4775 } |
4765 else | 4776 else |
5022 if (!newlist && (di = dict_find(what, (char_u *)"id", -1)) != NULL) | 5033 if (!newlist && (di = dict_find(what, (char_u *)"id", -1)) != NULL) |
5023 { | 5034 { |
5024 /* Use the quickfix/location list with the specified id */ | 5035 /* Use the quickfix/location list with the specified id */ |
5025 if (di->di_tv.v_type == VAR_NUMBER) | 5036 if (di->di_tv.v_type == VAR_NUMBER) |
5026 { | 5037 { |
5027 for (qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++) | 5038 qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number); |
5028 if (qi->qf_lists[qf_idx].qf_id == di->di_tv.vval.v_number) | 5039 if (qf_idx == -1) |
5029 break; | |
5030 if (qf_idx == qi->qf_listcount) | |
5031 return FAIL; /* List not found */ | 5040 return FAIL; /* List not found */ |
5032 } | 5041 } |
5033 else | 5042 else |
5034 return FAIL; | 5043 return FAIL; |
5035 } | 5044 } |
5060 { | 5069 { |
5061 char_u *title_save = vim_strsave(qi->qf_lists[qf_idx].qf_title); | 5070 char_u *title_save = vim_strsave(qi->qf_lists[qf_idx].qf_title); |
5062 | 5071 |
5063 retval = qf_add_entries(qi, qf_idx, di->di_tv.vval.v_list, | 5072 retval = qf_add_entries(qi, qf_idx, di->di_tv.vval.v_list, |
5064 title_save, action == ' ' ? 'a' : action); | 5073 title_save, action == ' ' ? 'a' : action); |
5074 if (action == 'r') | |
5075 { | |
5076 /* | |
5077 * When replacing the quickfix list entries using | |
5078 * qf_add_entries(), the title is set with a ':' prefix. | |
5079 * Restore the title with the saved title. | |
5080 */ | |
5081 vim_free(qi->qf_lists[qf_idx].qf_title); | |
5082 qi->qf_lists[qf_idx].qf_title = vim_strsave(title_save); | |
5083 } | |
5065 vim_free(title_save); | 5084 vim_free(title_save); |
5066 } | 5085 } |
5067 } | 5086 } |
5068 | 5087 |
5069 if ((di = dict_find(what, (char_u *)"efm", -1)) != NULL) | 5088 if ((di = dict_find(what, (char_u *)"efm", -1)) != NULL) |