forked from aniani/vim
patch 8.1.0532: cannot distinguish between quickfix and location list
Problem: Cannot distinguish between quickfix and location list. Solution: Add an explicit type variable. (Yegappan Lakshmanan)
This commit is contained in:
parent
dbc0d2163a
commit
2d67d307ee
@ -49,6 +49,16 @@ struct qfline_S
|
|||||||
#define LISTCOUNT 10
|
#define LISTCOUNT 10
|
||||||
#define INVALID_QFIDX (-1)
|
#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
|
* Quickfix/Location list definition
|
||||||
* Contains a list of entries (qfline_T). qf_start points to the first entry
|
* Contains a list of entries (qfline_T). qf_start points to the first entry
|
||||||
@ -61,6 +71,7 @@ struct qfline_S
|
|||||||
typedef struct qf_list_S
|
typedef struct qf_list_S
|
||||||
{
|
{
|
||||||
int_u qf_id; // Unique identifier for this list
|
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_start; // pointer to the first error
|
||||||
qfline_T *qf_last; // pointer to the last error
|
qfline_T *qf_last; // pointer to the last error
|
||||||
qfline_T *qf_ptr; // pointer to the current error
|
qfline_T *qf_ptr; // pointer to the current error
|
||||||
@ -95,6 +106,7 @@ struct qf_info_S
|
|||||||
int qf_listcount; // current number of lists
|
int qf_listcount; // current number of lists
|
||||||
int qf_curlist; // current error list
|
int qf_curlist; // current error list
|
||||||
qf_list_T qf_lists[LISTCOUNT];
|
qf_list_T qf_lists[LISTCOUNT];
|
||||||
|
qfltype_T qfl_type; // type of list
|
||||||
};
|
};
|
||||||
|
|
||||||
static qf_info_T ql_info; // global quickfix list
|
static qf_info_T ql_info; // global quickfix list
|
||||||
@ -170,8 +182,10 @@ static qf_info_T *ll_get_or_alloc_list(win_T *);
|
|||||||
#define IS_LL_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
|
#define IS_LL_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
|
||||||
|
|
||||||
// Quickfix and location list stack check helper macros
|
// Quickfix and location list stack check helper macros
|
||||||
#define IS_QF_STACK(qi) (qi == &ql_info)
|
#define IS_QF_STACK(qi) (qi->qfl_type == QFLT_QUICKFIX)
|
||||||
#define IS_LL_STACK(qi) (qi != &ql_info)
|
#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'
|
* Return location list for window 'wp'
|
||||||
@ -1847,6 +1861,7 @@ qf_new_list(qf_info_T *qi, char_u *qf_title)
|
|||||||
qfl = &qi->qf_lists[qi->qf_curlist];
|
qfl = &qi->qf_lists[qi->qf_curlist];
|
||||||
vim_memset(qfl, 0, (size_t)(sizeof(qf_list_T)));
|
vim_memset(qfl, 0, (size_t)(sizeof(qf_list_T)));
|
||||||
qf_store_title(qfl, qf_title);
|
qf_store_title(qfl, qf_title);
|
||||||
|
qfl->qfl_type = qi->qfl_type;
|
||||||
qfl->qf_id = ++last_qf_id;
|
qfl->qf_id = ++last_qf_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2007,7 +2022,7 @@ qf_add_entry(
|
|||||||
qfp->qf_fnum = bufnum;
|
qfp->qf_fnum = bufnum;
|
||||||
if (buf != NULL)
|
if (buf != NULL)
|
||||||
buf->b_has_qf_entry |=
|
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
|
else
|
||||||
qfp->qf_fnum = qf_get_fnum(qi, qf_idx, dir, fname);
|
qfp->qf_fnum = qf_get_fnum(qi, qf_idx, dir, fname);
|
||||||
@ -2069,16 +2084,19 @@ qf_add_entry(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate a new location list stack
|
* Allocate a new quickfix/location list stack
|
||||||
*/
|
*/
|
||||||
static qf_info_T *
|
static qf_info_T *
|
||||||
ll_new_list(void)
|
qf_alloc_stack(qfltype_T qfltype)
|
||||||
{
|
{
|
||||||
qf_info_T *qi;
|
qf_info_T *qi;
|
||||||
|
|
||||||
qi = (qf_info_T *)alloc_clear((unsigned)sizeof(qf_info_T));
|
qi = (qf_info_T *)alloc_clear((unsigned)sizeof(qf_info_T));
|
||||||
if (qi != NULL)
|
if (qi != NULL)
|
||||||
|
{
|
||||||
qi->qf_refcount++;
|
qi->qf_refcount++;
|
||||||
|
qi->qfl_type = qfltype;
|
||||||
|
}
|
||||||
return qi;
|
return qi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2098,7 +2116,7 @@ ll_get_or_alloc_list(win_T *wp)
|
|||||||
ll_free_all(&wp->w_llist_ref);
|
ll_free_all(&wp->w_llist_ref);
|
||||||
|
|
||||||
if (wp->w_llist == NULL)
|
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;
|
return wp->w_llist;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2153,6 +2171,7 @@ copy_loclist_entries(qf_list_T *from_qfl, qf_list_T *to_qfl, qf_info_T *to_qi)
|
|||||||
copy_loclist(qf_list_T *from_qfl, qf_list_T *to_qfl, qf_info_T *to_qi)
|
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()
|
// 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_nonevalid = from_qfl->qf_nonevalid;
|
||||||
to_qfl->qf_count = 0;
|
to_qfl->qf_count = 0;
|
||||||
to_qfl->qf_index = 0;
|
to_qfl->qf_index = 0;
|
||||||
@ -2214,7 +2233,7 @@ copy_loclist_stack(win_T *from, win_T *to)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// allocate a new location list
|
// allocate a new location list
|
||||||
if ((to->w_llist = ll_new_list()) == NULL)
|
if ((to->w_llist = qf_alloc_stack(QFLT_LOCATION)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
to->w_llist->qf_listcount = qi->qf_listcount;
|
to->w_llist->qf_listcount = qi->qf_listcount;
|
||||||
@ -2300,7 +2319,7 @@ qf_get_fnum(qf_info_T *qi, int qf_idx, char_u *directory, char_u *fname)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
buf->b_has_qf_entry =
|
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;
|
return buf->b_fnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2995,6 +3014,7 @@ qf_jump_edit_buffer(
|
|||||||
int *opened_window)
|
int *opened_window)
|
||||||
{
|
{
|
||||||
qf_list_T *qfl = &qi->qf_lists[qi->qf_curlist];
|
qf_list_T *qfl = &qi->qf_lists[qi->qf_curlist];
|
||||||
|
qfltype_T qfl_type = qfl->qfl_type;
|
||||||
int retval = OK;
|
int retval = OK;
|
||||||
int old_qf_curlist = qi->qf_curlist;
|
int old_qf_curlist = qi->qf_curlist;
|
||||||
int save_qfid = qfl->qf_id;
|
int save_qfid = qfl->qf_id;
|
||||||
@ -3019,14 +3039,14 @@ qf_jump_edit_buffer(
|
|||||||
|
|
||||||
// If a location list, check whether the associated window is still
|
// If a location list, check whether the associated window is still
|
||||||
// present.
|
// 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"));
|
EMSG(_("E924: Current window was closed"));
|
||||||
*opened_window = FALSE;
|
*opened_window = FALSE;
|
||||||
return NOTDONE;
|
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"));
|
EMSG(_("E925: Current quickfix was changed"));
|
||||||
return NOTDONE;
|
return NOTDONE;
|
||||||
@ -3035,7 +3055,7 @@ qf_jump_edit_buffer(
|
|||||||
if (old_qf_curlist != qi->qf_curlist
|
if (old_qf_curlist != qi->qf_curlist
|
||||||
|| !is_qf_entry_present(qfl, qf_ptr))
|
|| !is_qf_entry_present(qfl, qf_ptr))
|
||||||
{
|
{
|
||||||
if (IS_QF_STACK(qi))
|
if (qfl_type == QFLT_QUICKFIX)
|
||||||
EMSG(_("E925: Current quickfix was changed"));
|
EMSG(_("E925: Current quickfix was changed"));
|
||||||
else
|
else
|
||||||
EMSG(_(e_loc_list_changed));
|
EMSG(_(e_loc_list_changed));
|
||||||
@ -5896,7 +5916,7 @@ qf_get_list_from_lines(dict_T *what, dictitem_T *di, dict_T *retdict)
|
|||||||
if (l == NULL)
|
if (l == NULL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
qi = ll_new_list();
|
qi = qf_alloc_stack(QFLT_INTERNAL);
|
||||||
if (qi != NULL)
|
if (qi != NULL)
|
||||||
{
|
{
|
||||||
if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat,
|
if (qf_init_ext(qi, 0, NULL, NULL, &di->di_tv, errorformat,
|
||||||
@ -6040,7 +6060,7 @@ qf_getprop_qfidx(qf_info_T *qi, dict_T *what)
|
|||||||
* Return default values for quickfix list properties in retdict.
|
* Return default values for quickfix list properties in retdict.
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
int status = OK;
|
||||||
|
|
||||||
@ -6068,7 +6088,7 @@ qf_getprop_defaults(qf_info_T *qi, int flags, dict_T *retdict)
|
|||||||
status = dict_add_number(retdict, "size", 0);
|
status = dict_add_number(retdict, "size", 0);
|
||||||
if ((status == OK) && (flags & QF_GETLIST_TICK))
|
if ((status == OK) && (flags & QF_GETLIST_TICK))
|
||||||
status = dict_add_number(retdict, "changedtick", 0);
|
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);
|
status = dict_add_number(retdict, "filewinid", 0);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
@ -6191,7 +6211,7 @@ qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
|
|||||||
|
|
||||||
// List is not present or is empty
|
// List is not present or is empty
|
||||||
if (qf_stack_empty(qi) || qf_idx == INVALID_QFIDX)
|
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];
|
qfl = &qi->qf_lists[qf_idx];
|
||||||
|
|
||||||
@ -6616,7 +6636,7 @@ qf_free_stack(win_T *wp, qf_info_T *qi)
|
|||||||
{
|
{
|
||||||
// If the location list window is open, then create a new empty
|
// If the location list window is open, then create a new empty
|
||||||
// location list
|
// 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
|
// first free the list reference in the location list window
|
||||||
ll_free_all(&orig_wp->w_llist_ref);
|
ll_free_all(&orig_wp->w_llist_ref);
|
||||||
@ -6964,7 +6984,7 @@ hgr_get_ll(int *new_ll)
|
|||||||
if (qi == NULL)
|
if (qi == NULL)
|
||||||
{
|
{
|
||||||
// Allocate a new location list for help text matches
|
// 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;
|
return NULL;
|
||||||
*new_ll = TRUE;
|
*new_ll = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -792,6 +792,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
532,
|
||||||
/**/
|
/**/
|
||||||
531,
|
531,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user