#define LISTCOUNT 10
#define INVALID_QFIDX (-1)
+/*
+ * Quickfix list type.
+ */
+typedef enum
+{
+ QFLT_QUICKFIX, // Quickfix list - global list
+ QFLT_LOCATION, // Location list - per window list
+ QFLT_INTERNAL // Internal - Temporary list used by getqflist()/getloclist()
+} qfltype_T;
+
/*
* Quickfix/Location list definition
* Contains a list of entries (qfline_T). qf_start points to the first entry
typedef struct qf_list_S
{
int_u qf_id; // Unique identifier for this list
+ qfltype_T qfl_type;
qfline_T *qf_start; // pointer to the first error
qfline_T *qf_last; // pointer to the last error
qfline_T *qf_ptr; // pointer to the current error
int qf_listcount; // current number of lists
int qf_curlist; // current error list
qf_list_T qf_lists[LISTCOUNT];
+ qfltype_T qfl_type; // type of list
};
static qf_info_T ql_info; // global quickfix list
#define IS_LL_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
// Quickfix and location list stack check helper macros
-#define IS_QF_STACK(qi) (qi == &ql_info)
-#define IS_LL_STACK(qi) (qi != &ql_info)
+#define IS_QF_STACK(qi) (qi->qfl_type == QFLT_QUICKFIX)
+#define IS_LL_STACK(qi) (qi->qfl_type == QFLT_LOCATION)
+#define IS_QF_LIST(qfl) (qfl->qfl_type == QFLT_QUICKFIX)
+#define IS_LL_LIST(qfl) (qfl->qfl_type == QFLT_LOCATION)
/*
* Return location list for window 'wp'
qfl = &qi->qf_lists[qi->qf_curlist];
vim_memset(qfl, 0, (size_t)(sizeof(qf_list_T)));
qf_store_title(qfl, qf_title);
+ qfl->qfl_type = qi->qfl_type;
qfl->qf_id = ++last_qf_id;
}
qfp->qf_fnum = bufnum;
if (buf != NULL)
buf->b_has_qf_entry |=
- IS_QF_STACK(qi) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY;
+ IS_QF_LIST(qfl) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY;
}
else
qfp->qf_fnum = qf_get_fnum(qi, qf_idx, dir, fname);
}
/*
- * Allocate a new location list stack
+ * Allocate a new quickfix/location list stack
*/
static qf_info_T *
-ll_new_list(void)
+qf_alloc_stack(qfltype_T qfltype)
{
qf_info_T *qi;
qi = (qf_info_T *)alloc_clear((unsigned)sizeof(qf_info_T));
if (qi != NULL)
+ {
qi->qf_refcount++;
+ qi->qfl_type = qfltype;
+ }
return qi;
}
ll_free_all(&wp->w_llist_ref);
if (wp->w_llist == NULL)
- wp->w_llist = ll_new_list(); // new location list
+ wp->w_llist = qf_alloc_stack(QFLT_LOCATION); // new location list
return wp->w_llist;
}
copy_loclist(qf_list_T *from_qfl, qf_list_T *to_qfl, qf_info_T *to_qi)
{
// Some of the fields are populated by qf_add_entry()
+ to_qfl->qfl_type = from_qfl->qfl_type;
to_qfl->qf_nonevalid = from_qfl->qf_nonevalid;
to_qfl->qf_count = 0;
to_qfl->qf_index = 0;
return;
// allocate a new location list
- if ((to->w_llist = ll_new_list()) == NULL)
+ if ((to->w_llist = qf_alloc_stack(QFLT_LOCATION)) == NULL)
return;
to->w_llist->qf_listcount = qi->qf_listcount;
return 0;
buf->b_has_qf_entry =
- IS_QF_STACK(qi) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY;
+ IS_QF_LIST(qfl) ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY;
return buf->b_fnum;
}
int *opened_window)
{
qf_list_T *qfl = &qi->qf_lists[qi->qf_curlist];
+ qfltype_T qfl_type = qfl->qfl_type;
int retval = OK;
int old_qf_curlist = qi->qf_curlist;
int save_qfid = qfl->qf_id;
// If a location list, check whether the associated window is still
// present.
- if (IS_LL_STACK(qi) && !win_valid_any_tab(oldwin))
+ if (qfl_type == QFLT_LOCATION && !win_valid_any_tab(oldwin))
{
EMSG(_("E924: Current window was closed"));
*opened_window = FALSE;
return NOTDONE;
}
- if (IS_QF_STACK(qi) && !qflist_valid(NULL, save_qfid))
+ if (qfl_type == QFLT_QUICKFIX && !qflist_valid(NULL, save_qfid))
{
EMSG(_("E925: Current quickfix was changed"));
return NOTDONE;
if (old_qf_curlist != qi->qf_curlist
|| !is_qf_entry_present(qfl, qf_ptr))
{
- if (IS_QF_STACK(qi))
+ if (qfl_type == QFLT_QUICKFIX)
EMSG(_("E925: Current quickfix was changed"));
else
EMSG(_(e_loc_list_changed));
if (l == NULL)
return FAIL;
- qi = ll_new_list();
+ qi = qf_alloc_stack(QFLT_INTERNAL);
if (qi != NULL)
{
if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat,
* Return default values for quickfix list properties in retdict.
*/
static int
-qf_getprop_defaults(qf_info_T *qi, int flags, dict_T *retdict)
+qf_getprop_defaults(qf_info_T *qi, int flags, int locstack, dict_T *retdict)
{
int status = OK;
status = dict_add_number(retdict, "size", 0);
if ((status == OK) && (flags & QF_GETLIST_TICK))
status = dict_add_number(retdict, "changedtick", 0);
- if ((status == OK) && IS_LL_STACK(qi) && (flags & QF_GETLIST_FILEWINID))
+ if ((status == OK) && locstack && (flags & QF_GETLIST_FILEWINID))
status = dict_add_number(retdict, "filewinid", 0);
return status;
// List is not present or is empty
if (qf_stack_empty(qi) || qf_idx == INVALID_QFIDX)
- return qf_getprop_defaults(qi, flags, retdict);
+ return qf_getprop_defaults(qi, flags, wp != NULL, retdict);
qfl = &qi->qf_lists[qf_idx];
{
// If the location list window is open, then create a new empty
// location list
- qf_info_T *new_ll = ll_new_list();
+ qf_info_T *new_ll = qf_alloc_stack(QFLT_LOCATION);
// first free the list reference in the location list window
ll_free_all(&orig_wp->w_llist_ref);
if (qi == NULL)
{
// Allocate a new location list for help text matches
- if ((qi = ll_new_list()) == NULL)
+ if ((qi = qf_alloc_stack(QFLT_LOCATION)) == NULL)
return NULL;
*new_ll = TRUE;
}