comparison src/quickfix.c @ 14664:8770189c3e22 v8.1.0345

patch 8.1.0345: cannot get the window id associated with the location list commit https://github.com/vim/vim/commit/c9cc9c78f21caba7ecb5c90403df5e19a57aa96a Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 2 15:18:42 2018 +0200 patch 8.1.0345: cannot get the window id associated with the location list Problem: Cannot get the window id associated with the location list. Solution: Add the "filewinid" argument to getloclist(). (Yegappan Lakshmanan, closes #3202)
author Christian Brabandt <cb@256bit.org>
date Sun, 02 Sep 2018 15:30:08 +0200
parents 462087b5c415
children 3ca7aba1116e
comparison
equal deleted inserted replaced
14663:0612ac666447 14664:8770189c3e22
5668 QF_GETLIST_CONTEXT = 0x10, 5668 QF_GETLIST_CONTEXT = 0x10,
5669 QF_GETLIST_ID = 0x20, 5669 QF_GETLIST_ID = 0x20,
5670 QF_GETLIST_IDX = 0x40, 5670 QF_GETLIST_IDX = 0x40,
5671 QF_GETLIST_SIZE = 0x80, 5671 QF_GETLIST_SIZE = 0x80,
5672 QF_GETLIST_TICK = 0x100, 5672 QF_GETLIST_TICK = 0x100,
5673 QF_GETLIST_ALL = 0x1FF, 5673 QF_GETLIST_FILEWINID = 0x200,
5674 QF_GETLIST_ALL = 0x3FF,
5674 }; 5675 };
5675 5676
5676 /* 5677 /*
5677 * Parse text from 'di' and return the quickfix list items. 5678 * Parse text from 'di' and return the quickfix list items.
5678 * Existing quickfix lists are not modified. 5679 * Existing quickfix lists are not modified.
5742 5743
5743 /* 5744 /*
5744 * Convert the keys in 'what' to quickfix list property flags. 5745 * Convert the keys in 'what' to quickfix list property flags.
5745 */ 5746 */
5746 static int 5747 static int
5747 qf_getprop_keys2flags(dict_T *what) 5748 qf_getprop_keys2flags(dict_T *what, int loclist)
5748 { 5749 {
5749 int flags = QF_GETLIST_NONE; 5750 int flags = QF_GETLIST_NONE;
5750 5751
5751 if (dict_find(what, (char_u *)"all", -1) != NULL) 5752 if (dict_find(what, (char_u *)"all", -1) != NULL)
5753 {
5752 flags |= QF_GETLIST_ALL; 5754 flags |= QF_GETLIST_ALL;
5755 if (!loclist)
5756 // File window ID is applicable only to location list windows
5757 flags &= ~ QF_GETLIST_FILEWINID;
5758 }
5753 5759
5754 if (dict_find(what, (char_u *)"title", -1) != NULL) 5760 if (dict_find(what, (char_u *)"title", -1) != NULL)
5755 flags |= QF_GETLIST_TITLE; 5761 flags |= QF_GETLIST_TITLE;
5756 5762
5757 if (dict_find(what, (char_u *)"nr", -1) != NULL) 5763 if (dict_find(what, (char_u *)"nr", -1) != NULL)
5775 if (dict_find(what, (char_u *)"size", -1) != NULL) 5781 if (dict_find(what, (char_u *)"size", -1) != NULL)
5776 flags |= QF_GETLIST_SIZE; 5782 flags |= QF_GETLIST_SIZE;
5777 5783
5778 if (dict_find(what, (char_u *)"changedtick", -1) != NULL) 5784 if (dict_find(what, (char_u *)"changedtick", -1) != NULL)
5779 flags |= QF_GETLIST_TICK; 5785 flags |= QF_GETLIST_TICK;
5786
5787 if (loclist && dict_find(what, (char_u *)"filewinid", -1) != NULL)
5788 flags |= QF_GETLIST_FILEWINID;
5780 5789
5781 return flags; 5790 return flags;
5782 } 5791 }
5783 5792
5784 /* 5793 /*
5868 status = dict_add_number(retdict, "idx", 0); 5877 status = dict_add_number(retdict, "idx", 0);
5869 if ((status == OK) && (flags & QF_GETLIST_SIZE)) 5878 if ((status == OK) && (flags & QF_GETLIST_SIZE))
5870 status = dict_add_number(retdict, "size", 0); 5879 status = dict_add_number(retdict, "size", 0);
5871 if ((status == OK) && (flags & QF_GETLIST_TICK)) 5880 if ((status == OK) && (flags & QF_GETLIST_TICK))
5872 status = dict_add_number(retdict, "changedtick", 0); 5881 status = dict_add_number(retdict, "changedtick", 0);
5882 if ((status == OK) && (qi != &ql_info) && (flags & QF_GETLIST_FILEWINID))
5883 status = dict_add_number(retdict, "filewinid", 0);
5873 5884
5874 return status; 5885 return status;
5875 } 5886 }
5876 5887
5877 /* 5888 /*
5879 */ 5890 */
5880 static int 5891 static int
5881 qf_getprop_title(qf_info_T *qi, int qf_idx, dict_T *retdict) 5892 qf_getprop_title(qf_info_T *qi, int qf_idx, dict_T *retdict)
5882 { 5893 {
5883 return dict_add_string(retdict, "title", qi->qf_lists[qf_idx].qf_title); 5894 return dict_add_string(retdict, "title", qi->qf_lists[qf_idx].qf_title);
5895 }
5896
5897 /*
5898 * Returns the identifier of the window used to display files from a location
5899 * list. If there is no associated window, then returns 0. Useful only when
5900 * called from a location list window.
5901 */
5902 static int
5903 qf_getprop_filewinid(win_T *wp, qf_info_T *qi, dict_T *retdict)
5904 {
5905 int winid = 0;
5906
5907 if (wp != NULL && IS_LL_WINDOW(wp))
5908 {
5909 win_T *ll_wp = qf_find_win_with_loclist(qi);
5910 if (ll_wp != NULL)
5911 winid = ll_wp->w_id;
5912 }
5913
5914 return dict_add_number(retdict, "filewinid", winid);
5884 } 5915 }
5885 5916
5886 /* 5917 /*
5887 * Return the quickfix list items/entries as 'items' in retdict 5918 * Return the quickfix list items/entries as 'items' in retdict
5888 */ 5919 */
5961 return qf_get_list_from_lines(what, di, retdict); 5992 return qf_get_list_from_lines(what, di, retdict);
5962 5993
5963 if (wp != NULL) 5994 if (wp != NULL)
5964 qi = GET_LOC_LIST(wp); 5995 qi = GET_LOC_LIST(wp);
5965 5996
5966 flags = qf_getprop_keys2flags(what); 5997 flags = qf_getprop_keys2flags(what, (wp != NULL));
5967 5998
5968 if (qi != NULL && qi->qf_listcount != 0) 5999 if (qi != NULL && qi->qf_listcount != 0)
5969 qf_idx = qf_getprop_qfidx(qi, what); 6000 qf_idx = qf_getprop_qfidx(qi, what);
5970 6001
5971 /* List is not present or is empty */ 6002 /* List is not present or is empty */
5990 status = dict_add_number(retdict, "size", 6021 status = dict_add_number(retdict, "size",
5991 qi->qf_lists[qf_idx].qf_count); 6022 qi->qf_lists[qf_idx].qf_count);
5992 if ((status == OK) && (flags & QF_GETLIST_TICK)) 6023 if ((status == OK) && (flags & QF_GETLIST_TICK))
5993 status = dict_add_number(retdict, "changedtick", 6024 status = dict_add_number(retdict, "changedtick",
5994 qi->qf_lists[qf_idx].qf_changedtick); 6025 qi->qf_lists[qf_idx].qf_changedtick);
6026 if ((status == OK) && (wp != NULL) && (flags & QF_GETLIST_FILEWINID))
6027 status = qf_getprop_filewinid(wp, qi, retdict);
5995 6028
5996 return status; 6029 return status;
5997 } 6030 }
5998 6031
5999 /* 6032 /*