mirror of
https://github.com/neovim/neovim.git
synced 2025-09-21 10:48:18 +00:00
vim-patch:8.1.1030: quickfix function arguments are inconsistent
Problem: Quickfix function arguments are inconsistent.
Solution: Pass a list pointer instead of info and index. (Yegappan
Lakshmanan, closes vim/vim#4135)
0398e00a1b
This commit is contained in:
@@ -845,24 +845,26 @@ static bool qf_stack_empty(const qf_info_T *qi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the specified quickfix/location list is empty.
|
// Returns true if the specified quickfix/location list is empty.
|
||||||
static bool qf_list_empty(const qf_info_T *qi, int qf_idx)
|
static bool qf_list_empty(qf_list_T *qfl)
|
||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
if (qi == NULL || qf_idx < 0 || qf_idx >= LISTCOUNT) {
|
return qfl == NULL || qfl->qf_count <= 0;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
return qi->qf_lists[qf_idx].qf_count <= 0;
|
// Return a pointer to a list in the specified quickfix stack
|
||||||
|
static qf_list_T * qf_get_list(qf_info_T *qi, int idx)
|
||||||
|
{
|
||||||
|
return &qi->qf_lists[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse a line and get the quickfix fields.
|
/// Parse a line and get the quickfix fields.
|
||||||
/// Return the QF_ status.
|
/// Return the QF_ status.
|
||||||
static int qf_parse_line(qf_info_T *qi, int qf_idx, char_u *linebuf,
|
static int qf_parse_line(qf_list_T *qfl, char_u *linebuf,
|
||||||
size_t linelen, efm_T *fmt_first, qffields_T *fields)
|
size_t linelen, efm_T *fmt_first, qffields_T *fields)
|
||||||
{
|
{
|
||||||
efm_T *fmt_ptr;
|
efm_T *fmt_ptr;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
char_u *tail = NULL;
|
char_u *tail = NULL;
|
||||||
qf_list_T *qfl = &qi->qf_lists[qf_idx];
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
restofline:
|
restofline:
|
||||||
@@ -918,7 +920,7 @@ restofline:
|
|||||||
qfl->qf_multiignore = false; // reset continuation
|
qfl->qf_multiignore = false; // reset continuation
|
||||||
} else if (vim_strchr((char_u *)"CZ", idx) != NULL) {
|
} else if (vim_strchr((char_u *)"CZ", idx) != NULL) {
|
||||||
// continuation of multi-line msg
|
// continuation of multi-line msg
|
||||||
status = qf_parse_multiline_pfx(qi, qf_idx, idx, qfl, fields);
|
status = qf_parse_multiline_pfx(idx, qfl, fields);
|
||||||
if (status != QF_OK) {
|
if (status != QF_OK) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -1064,12 +1066,12 @@ qf_init_ext(
|
|||||||
} else {
|
} else {
|
||||||
// Adding to existing list, use last entry.
|
// Adding to existing list, use last entry.
|
||||||
adding = true;
|
adding = true;
|
||||||
if (!qf_list_empty(qi, qf_idx)) {
|
if (!qf_list_empty(qf_get_list(qi, qf_idx) )) {
|
||||||
old_last = qi->qf_lists[qf_idx].qf_last;
|
old_last = qi->qf_lists[qf_idx].qf_last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qf_list_T *qfl = &qi->qf_lists[qf_idx];
|
qf_list_T *qfl = qf_get_list(qi, qf_idx);
|
||||||
|
|
||||||
// Use the local value of 'errorformat' if it's set.
|
// Use the local value of 'errorformat' if it's set.
|
||||||
if (errorformat == p_efm && tv == NULL && buf && *buf->b_p_efm != NUL) {
|
if (errorformat == p_efm && tv == NULL && buf && *buf->b_p_efm != NUL) {
|
||||||
@@ -1113,7 +1115,7 @@ qf_init_ext(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = qf_parse_line(qi, qf_idx, state.linebuf, state.linelen,
|
status = qf_parse_line(qfl, state.linebuf, state.linelen,
|
||||||
fmt_first, &fields);
|
fmt_first, &fields);
|
||||||
if (status == QF_FAIL) {
|
if (status == QF_FAIL) {
|
||||||
goto error2;
|
goto error2;
|
||||||
@@ -1122,8 +1124,7 @@ qf_init_ext(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qf_add_entry(qi,
|
if (qf_add_entry(qfl,
|
||||||
qf_idx,
|
|
||||||
qfl->qf_directory,
|
qfl->qf_directory,
|
||||||
(*fields.namebuf || qfl->qf_directory)
|
(*fields.namebuf || qfl->qf_directory)
|
||||||
? fields.namebuf : ((qfl->qf_currfile && fields.valid)
|
? fields.namebuf : ((qfl->qf_currfile && fields.valid)
|
||||||
@@ -1210,7 +1211,7 @@ static char_u * qf_cmdtitle(char_u *cmd)
|
|||||||
// Return a pointer to the current list in the specified quickfix stack
|
// Return a pointer to the current list in the specified quickfix stack
|
||||||
static qf_list_T * qf_get_curlist(qf_info_T *qi)
|
static qf_list_T * qf_get_curlist(qf_info_T *qi)
|
||||||
{
|
{
|
||||||
return &qi->qf_lists[qi->qf_curlist];
|
return qf_get_list(qi, qi->qf_curlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare for adding a new quickfix list. If the current list is in the
|
// Prepare for adding a new quickfix list. If the current list is in the
|
||||||
@@ -1616,8 +1617,7 @@ static int qf_parse_line_nomatch(char_u *linebuf, size_t linelen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parse multi-line error format prefixes (%C and %Z)
|
/// Parse multi-line error format prefixes (%C and %Z)
|
||||||
static int qf_parse_multiline_pfx(qf_info_T *qi, int qf_idx, int idx,
|
static int qf_parse_multiline_pfx(int idx, qf_list_T *qfl, qffields_T *fields)
|
||||||
qf_list_T *qfl, qffields_T *fields)
|
|
||||||
{
|
{
|
||||||
if (!qfl->qf_multiignore) {
|
if (!qfl->qf_multiignore) {
|
||||||
qfline_T *qfprev = qfl->qf_last;
|
qfline_T *qfprev = qfl->qf_last;
|
||||||
@@ -1648,7 +1648,7 @@ static int qf_parse_multiline_pfx(qf_info_T *qi, int qf_idx, int idx,
|
|||||||
}
|
}
|
||||||
qfprev->qf_viscol = fields->use_viscol;
|
qfprev->qf_viscol = fields->use_viscol;
|
||||||
if (!qfprev->qf_fnum) {
|
if (!qfprev->qf_fnum) {
|
||||||
qfprev->qf_fnum = qf_get_fnum(qi, qf_idx, qfl->qf_directory,
|
qfprev->qf_fnum = qf_get_fnum(qfl, qfl->qf_directory,
|
||||||
*fields->namebuf || qfl->qf_directory
|
*fields->namebuf || qfl->qf_directory
|
||||||
? fields->namebuf
|
? fields->namebuf
|
||||||
: qfl->qf_currfile && fields->valid
|
: qfl->qf_currfile && fields->valid
|
||||||
@@ -1694,7 +1694,7 @@ static void ll_free_all(qf_info_T **pqi)
|
|||||||
locstack_queue_delreq(qi);
|
locstack_queue_delreq(qi);
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < qi->qf_listcount; i++) {
|
for (i = 0; i < qi->qf_listcount; i++) {
|
||||||
qf_free(&qi->qf_lists[i]);
|
qf_free(qf_get_list(qi, i));
|
||||||
}
|
}
|
||||||
xfree(qi);
|
xfree(qi);
|
||||||
}
|
}
|
||||||
@@ -1714,7 +1714,7 @@ void qf_free_all(win_T *wp)
|
|||||||
} else {
|
} else {
|
||||||
// quickfix list
|
// quickfix list
|
||||||
for (i = 0; i < qi->qf_listcount; i++) {
|
for (i = 0; i < qi->qf_listcount; i++) {
|
||||||
qf_free(&qi->qf_lists[i]);
|
qf_free(qf_get_list(qi, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1765,8 +1765,7 @@ void check_quickfix_busy(void)
|
|||||||
|
|
||||||
/// Add an entry to the end of the list of errors.
|
/// Add an entry to the end of the list of errors.
|
||||||
///
|
///
|
||||||
/// @param qi quickfix list
|
/// @param qfl quickfix list entry
|
||||||
/// @param qf_idx list index
|
|
||||||
/// @param dir optional directory name
|
/// @param dir optional directory name
|
||||||
/// @param fname file name or NULL
|
/// @param fname file name or NULL
|
||||||
/// @param module module name or NULL
|
/// @param module module name or NULL
|
||||||
@@ -1781,12 +1780,11 @@ void check_quickfix_busy(void)
|
|||||||
/// @param valid valid entry
|
/// @param valid valid entry
|
||||||
///
|
///
|
||||||
/// @returns OK or FAIL.
|
/// @returns OK or FAIL.
|
||||||
static int qf_add_entry(qf_info_T *qi, int qf_idx, char_u *dir, char_u *fname,
|
static int qf_add_entry(qf_list_T *qfl, char_u *dir, char_u *fname,
|
||||||
char_u *module, int bufnum, char_u *mesg, long lnum,
|
char_u *module, int bufnum, char_u *mesg, long lnum,
|
||||||
int col, char_u vis_col, char_u *pattern, int nr,
|
int col, char_u vis_col, char_u *pattern, int nr,
|
||||||
char_u type, char_u valid)
|
char_u type, char_u valid)
|
||||||
{
|
{
|
||||||
qf_list_T *qfl = &qi->qf_lists[qf_idx];
|
|
||||||
qfline_T *qfp = xmalloc(sizeof(qfline_T));
|
qfline_T *qfp = xmalloc(sizeof(qfline_T));
|
||||||
qfline_T **lastp; // pointer to qf_last or NULL
|
qfline_T **lastp; // pointer to qf_last or NULL
|
||||||
|
|
||||||
@@ -1799,7 +1797,7 @@ static int qf_add_entry(qf_info_T *qi, int qf_idx, char_u *dir, char_u *fname,
|
|||||||
IS_QF_LIST(qfl) ? 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(qfl, dir, fname);
|
||||||
}
|
}
|
||||||
qfp->qf_text = vim_strsave(mesg);
|
qfp->qf_text = vim_strsave(mesg);
|
||||||
qfp->qf_lnum = lnum;
|
qfp->qf_lnum = lnum;
|
||||||
@@ -1823,7 +1821,7 @@ static int qf_add_entry(qf_info_T *qi, int qf_idx, char_u *dir, char_u *fname,
|
|||||||
qfp->qf_valid = valid;
|
qfp->qf_valid = valid;
|
||||||
|
|
||||||
lastp = &qfl->qf_last;
|
lastp = &qfl->qf_last;
|
||||||
if (qf_list_empty(qi, qf_idx)) {
|
if (qf_list_empty(qfl)) {
|
||||||
// first element in the list
|
// first element in the list
|
||||||
qfl->qf_start = qfp;
|
qfl->qf_start = qfp;
|
||||||
qfl->qf_ptr = qfp;
|
qfl->qf_ptr = qfp;
|
||||||
@@ -1880,19 +1878,17 @@ static qf_info_T *ll_get_or_alloc_list(win_T *wp)
|
|||||||
|
|
||||||
// Copy location list entries from 'from_qfl' to 'to_qfl'.
|
// Copy location list entries from 'from_qfl' to 'to_qfl'.
|
||||||
static int copy_loclist_entries(const qf_list_T *from_qfl,
|
static int copy_loclist_entries(const qf_list_T *from_qfl,
|
||||||
qf_list_T *to_qfl,
|
qf_list_T *to_qfl)
|
||||||
qf_info_T *to_qi)
|
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const qfline_T *from_qfp;
|
qfline_T *from_qfp;
|
||||||
|
|
||||||
// copy all the location entries in this list
|
// copy all the location entries in this list
|
||||||
for (i = 0, from_qfp = from_qfl->qf_start;
|
for (i = 0, from_qfp = from_qfl->qf_start;
|
||||||
i < from_qfl->qf_count && from_qfp != NULL;
|
i < from_qfl->qf_count && from_qfp != NULL;
|
||||||
i++, from_qfp = from_qfp->qf_next) {
|
i++, from_qfp = from_qfp->qf_next) {
|
||||||
if (qf_add_entry(to_qi,
|
if (qf_add_entry(to_qfl,
|
||||||
to_qi->qf_curlist,
|
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
from_qfp->qf_module,
|
from_qfp->qf_module,
|
||||||
@@ -1923,9 +1919,7 @@ static int copy_loclist_entries(const qf_list_T *from_qfl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy the specified location list 'from_qfl' to 'to_qfl'.
|
// Copy the specified location list 'from_qfl' to 'to_qfl'.
|
||||||
static int copy_loclist(const qf_list_T *from_qfl,
|
static int copy_loclist(const qf_list_T *from_qfl, qf_list_T *to_qfl)
|
||||||
qf_list_T *to_qfl,
|
|
||||||
qf_info_T *to_qi)
|
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
// Some of the fields are populated by qf_add_entry()
|
// Some of the fields are populated by qf_add_entry()
|
||||||
@@ -1949,8 +1943,9 @@ static int copy_loclist(const qf_list_T *from_qfl,
|
|||||||
} else {
|
} else {
|
||||||
to_qfl->qf_ctx = NULL;
|
to_qfl->qf_ctx = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from_qfl->qf_count) {
|
if (from_qfl->qf_count) {
|
||||||
if (copy_loclist_entries(from_qfl, to_qfl, to_qi) == FAIL) {
|
if (copy_loclist_entries(from_qfl, to_qfl) == FAIL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1999,8 +1994,8 @@ void copy_loclist_stack(win_T *from, win_T *to)
|
|||||||
for (int idx = 0; idx < qi->qf_listcount; idx++) {
|
for (int idx = 0; idx < qi->qf_listcount; idx++) {
|
||||||
to->w_llist->qf_curlist = idx;
|
to->w_llist->qf_curlist = idx;
|
||||||
|
|
||||||
if (copy_loclist(&qi->qf_lists[idx], &to->w_llist->qf_lists[idx],
|
if (copy_loclist(qf_get_list(qi, idx),
|
||||||
to->w_llist) == FAIL) {
|
qf_get_list(to->w_llist, idx)) == FAIL) {
|
||||||
qf_free_all(to);
|
qf_free_all(to);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2011,10 +2006,8 @@ void copy_loclist_stack(win_T *from, win_T *to)
|
|||||||
|
|
||||||
// Get buffer number for file "directory/fname".
|
// Get buffer number for file "directory/fname".
|
||||||
// Also sets the b_has_qf_entry flag.
|
// Also sets the b_has_qf_entry flag.
|
||||||
static int qf_get_fnum(qf_info_T *qi, int qf_idx, char_u *directory,
|
static int qf_get_fnum(qf_list_T *qfl, char_u *directory, char_u *fname )
|
||||||
char_u *fname)
|
|
||||||
{
|
{
|
||||||
qf_list_T *qfl = &qi->qf_lists[qf_idx];
|
|
||||||
char_u *ptr = NULL;
|
char_u *ptr = NULL;
|
||||||
char_u *bufname;
|
char_u *bufname;
|
||||||
buf_T *buf;
|
buf_T *buf;
|
||||||
@@ -2534,7 +2527,7 @@ static void qf_goto_win_with_ll_file(win_T *use_win, int qf_fnum,
|
|||||||
|
|
||||||
// If the location list for the window is not set, then set it
|
// If the location list for the window is not set, then set it
|
||||||
// to the location list from the location window
|
// to the location list from the location window
|
||||||
if (win->w_llist == NULL) {
|
if (win->w_llist == NULL && ll_ref != NULL) {
|
||||||
// The new window should use the location list from the
|
// The new window should use the location list from the
|
||||||
// location list window
|
// location list window
|
||||||
win_set_loclist(win, ll_ref);
|
win_set_loclist(win, ll_ref);
|
||||||
@@ -2781,7 +2774,7 @@ void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit)
|
|||||||
if (qi == NULL)
|
if (qi == NULL)
|
||||||
qi = &ql_info;
|
qi = &ql_info;
|
||||||
|
|
||||||
if (qf_stack_empty(qi) || qf_list_empty(qi, qi->qf_curlist)) {
|
if (qf_stack_empty(qi) || qf_list_empty(qf_get_curlist(qi))) {
|
||||||
EMSG(_(e_quickfix));
|
EMSG(_(e_quickfix));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3005,7 +2998,7 @@ void qf_list(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qf_stack_empty(qi) || qf_list_empty(qi, qi->qf_curlist)) {
|
if (qf_stack_empty(qi) || qf_list_empty(qf_get_curlist(qi))) {
|
||||||
EMSG(_(e_quickfix));
|
EMSG(_(e_quickfix));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3177,7 +3170,7 @@ void qf_history(exarg_T *eap)
|
|||||||
if (is_loclist_cmd(eap->cmdidx)) {
|
if (is_loclist_cmd(eap->cmdidx)) {
|
||||||
qi = GET_LOC_LIST(curwin);
|
qi = GET_LOC_LIST(curwin);
|
||||||
}
|
}
|
||||||
if (qf_stack_empty(qi) || qf_list_empty(qi, qi->qf_curlist)) {
|
if (qf_stack_empty(qi) || qf_list_empty(qf_get_curlist(qi))) {
|
||||||
MSG(_("No entries"));
|
MSG(_("No entries"));
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < qi->qf_listcount; i++) {
|
for (i = 0; i < qi->qf_listcount; i++) {
|
||||||
@@ -3268,9 +3261,11 @@ bool qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (idx = 0; idx < qi->qf_listcount; idx++) {
|
for (idx = 0; idx < qi->qf_listcount; idx++) {
|
||||||
if (!qf_list_empty(qi, idx)) {
|
qf_list_T *qfl = qf_get_list(qi, idx);
|
||||||
for (i = 0, qfp = qi->qf_lists[idx].qf_start;
|
|
||||||
i < qi->qf_lists[idx].qf_count && qfp != NULL;
|
if (!qf_list_empty(qfl)) {
|
||||||
|
for (i = 0, qfp = qfl->qf_start;
|
||||||
|
i < qfl->qf_count && qfp != NULL;
|
||||||
i++, qfp = qfp->qf_next) {
|
i++, qfp = qfp->qf_next) {
|
||||||
if (qfp->qf_fnum == curbuf->b_fnum) {
|
if (qfp->qf_fnum == curbuf->b_fnum) {
|
||||||
found_one = true;
|
found_one = true;
|
||||||
@@ -3344,7 +3339,7 @@ void qf_view_result(bool split)
|
|||||||
if (IS_LL_WINDOW(curwin)) {
|
if (IS_LL_WINDOW(curwin)) {
|
||||||
qi = GET_LOC_LIST(curwin);
|
qi = GET_LOC_LIST(curwin);
|
||||||
}
|
}
|
||||||
if (qf_list_empty(qi, qi->qf_curlist)) {
|
if (qf_list_empty(qf_get_curlist(qi))) {
|
||||||
EMSG(_(e_quickfix));
|
EMSG(_(e_quickfix));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3394,7 +3389,7 @@ void ex_cwindow(exarg_T *eap)
|
|||||||
*/
|
*/
|
||||||
if (qf_stack_empty(qi)
|
if (qf_stack_empty(qi)
|
||||||
|| qfl->qf_nonevalid
|
|| qfl->qf_nonevalid
|
||||||
|| qf_list_empty(qi, qi->qf_curlist)) {
|
|| qf_list_empty(qf_get_curlist(qi))) {
|
||||||
if (win != NULL) {
|
if (win != NULL) {
|
||||||
ex_cclose(eap);
|
ex_cclose(eap);
|
||||||
}
|
}
|
||||||
@@ -3965,7 +3960,7 @@ static void qf_jump_first(qf_info_T *qi, unsigned save_qfid, int forceit)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Autocommands might have cleared the list, check for that
|
// Autocommands might have cleared the list, check for that
|
||||||
if (!qf_list_empty(qi, qi->qf_curlist)) {
|
if (!qf_list_empty(qf_get_curlist(qi))) {
|
||||||
qf_jump(qi, 0, 0, forceit);
|
qf_jump(qi, 0, 0, forceit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4613,8 +4608,7 @@ static bool vgr_match_buflines(qf_info_T *qi, char_u *fname, buf_T *buf,
|
|||||||
// Pass the buffer number so that it gets used even for a
|
// Pass the buffer number so that it gets used even for a
|
||||||
// dummy buffer, unless duplicate_name is set, then the
|
// dummy buffer, unless duplicate_name is set, then the
|
||||||
// buffer will be wiped out below.
|
// buffer will be wiped out below.
|
||||||
if (qf_add_entry(qi,
|
if (qf_add_entry(qf_get_curlist(qi),
|
||||||
qi->qf_curlist,
|
|
||||||
NULL, // dir
|
NULL, // dir
|
||||||
fname,
|
fname,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -4893,7 +4887,7 @@ void ex_vimgrep(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Jump to first match.
|
// Jump to first match.
|
||||||
if (!qf_list_empty(qi, qi->qf_curlist)) {
|
if (!qf_list_empty(qf_get_curlist(qi))) {
|
||||||
if ((flags & VGR_NOJUMP) == 0) {
|
if ((flags & VGR_NOJUMP) == 0) {
|
||||||
vgr_jump_to_match(qi, eap->forceit, &redraw_for_dummy, first_match_buf,
|
vgr_jump_to_match(qi, eap->forceit, &redraw_for_dummy, first_match_buf,
|
||||||
target_dir);
|
target_dir);
|
||||||
@@ -5084,6 +5078,7 @@ static void unload_dummy_buffer(buf_T *buf, char_u *dirname_start)
|
|||||||
int get_errorlist(const qf_info_T *qi_arg, win_T *wp, int qf_idx, list_T *list)
|
int get_errorlist(const qf_info_T *qi_arg, win_T *wp, int qf_idx, list_T *list)
|
||||||
{
|
{
|
||||||
const qf_info_T *qi = qi_arg;
|
const qf_info_T *qi = qi_arg;
|
||||||
|
qf_list_T *qfl;
|
||||||
char_u buf[2];
|
char_u buf[2];
|
||||||
qfline_T *qfp;
|
qfline_T *qfp;
|
||||||
int i;
|
int i;
|
||||||
@@ -5103,13 +5098,17 @@ int get_errorlist(const qf_info_T *qi_arg, win_T *wp, int qf_idx, list_T *list)
|
|||||||
qf_idx = qi->qf_curlist;
|
qf_idx = qi->qf_curlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qf_idx >= qi->qf_listcount
|
if (qf_idx >= qi->qf_listcount) {
|
||||||
|| qf_list_empty(qi, qf_idx)) {
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
qfp = qi->qf_lists[qf_idx].qf_start;
|
qfl = qf_get_list(qi, qf_idx);
|
||||||
for (i = 1; !got_int && i <= qi->qf_lists[qf_idx].qf_count; i++) {
|
if (qf_list_empty(qfl)) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
qfp = qfl->qf_start;
|
||||||
|
for (i = 1; !got_int && i <= qfl->qf_count; i++) {
|
||||||
// Handle entries with a non-existing buffer number.
|
// Handle entries with a non-existing buffer number.
|
||||||
bufnum = qfp->qf_fnum;
|
bufnum = qfp->qf_fnum;
|
||||||
if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
|
if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
|
||||||
@@ -5418,10 +5417,10 @@ static int qf_getprop_ctx(qf_list_T *qfl, dict_T *retdict)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return the current quickfix list index as 'idx' in retdict
|
/// Return the current quickfix list index as 'idx' in retdict
|
||||||
static int qf_getprop_idx(qf_info_T *qi, int qf_idx, dict_T *retdict)
|
static int qf_getprop_idx(qf_list_T *qfl, dict_T *retdict)
|
||||||
{
|
{
|
||||||
int curidx = qi->qf_lists[qf_idx].qf_index;
|
int curidx = qfl->qf_index;
|
||||||
if (qf_list_empty(qi, qf_idx)) {
|
if (qf_list_empty(qfl)) {
|
||||||
// For empty lists, current index is set to 0
|
// For empty lists, current index is set to 0
|
||||||
curidx = 0;
|
curidx = 0;
|
||||||
}
|
}
|
||||||
@@ -5458,7 +5457,7 @@ int qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
|
|||||||
return qf_getprop_defaults(qi, flags, wp != NULL, retdict);
|
return qf_getprop_defaults(qi, flags, wp != NULL, retdict);
|
||||||
}
|
}
|
||||||
|
|
||||||
qfl = &qi->qf_lists[qf_idx];
|
qfl = qf_get_list(qi, qf_idx);
|
||||||
|
|
||||||
if (flags & QF_GETLIST_TITLE) {
|
if (flags & QF_GETLIST_TITLE) {
|
||||||
status = qf_getprop_title(qfl, retdict);
|
status = qf_getprop_title(qfl, retdict);
|
||||||
@@ -5479,7 +5478,7 @@ int qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
|
|||||||
status = tv_dict_add_nr(retdict, S_LEN("id"), qfl->qf_id);
|
status = tv_dict_add_nr(retdict, S_LEN("id"), qfl->qf_id);
|
||||||
}
|
}
|
||||||
if ((status == OK) && (flags & QF_GETLIST_IDX)) {
|
if ((status == OK) && (flags & QF_GETLIST_IDX)) {
|
||||||
status = qf_getprop_idx(qi, qf_idx, retdict);
|
status = qf_getprop_idx(qfl, retdict);
|
||||||
}
|
}
|
||||||
if ((status == OK) && (flags & QF_GETLIST_SIZE)) {
|
if ((status == OK) && (flags & QF_GETLIST_SIZE)) {
|
||||||
status = tv_dict_add_nr(retdict, S_LEN("size"),
|
status = tv_dict_add_nr(retdict, S_LEN("size"),
|
||||||
@@ -5499,8 +5498,7 @@ int qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
|
|||||||
// Add a new quickfix entry to list at 'qf_idx' in the stack 'qi' from the
|
// Add a new quickfix entry to list at 'qf_idx' in the stack 'qi' from the
|
||||||
// items in the dict 'd'.
|
// items in the dict 'd'.
|
||||||
static int qf_add_entry_from_dict(
|
static int qf_add_entry_from_dict(
|
||||||
qf_info_T *qi,
|
qf_list_T *qfl,
|
||||||
int qf_idx,
|
|
||||||
const dict_T *d,
|
const dict_T *d,
|
||||||
bool first_entry)
|
bool first_entry)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
@@ -5546,8 +5544,7 @@ static int qf_add_entry_from_dict(
|
|||||||
valid = tv_dict_get_number(d, "valid");
|
valid = tv_dict_get_number(d, "valid");
|
||||||
}
|
}
|
||||||
|
|
||||||
const int status = qf_add_entry(qi,
|
const int status = qf_add_entry(qfl,
|
||||||
qf_idx,
|
|
||||||
NULL, // dir
|
NULL, // dir
|
||||||
(char_u *)filename,
|
(char_u *)filename,
|
||||||
(char_u *)module,
|
(char_u *)module,
|
||||||
@@ -5574,7 +5571,7 @@ static int qf_add_entry_from_dict(
|
|||||||
static int qf_add_entries(qf_info_T *qi, int qf_idx, list_T *list,
|
static int qf_add_entries(qf_info_T *qi, int qf_idx, list_T *list,
|
||||||
char_u *title, int action)
|
char_u *title, int action)
|
||||||
{
|
{
|
||||||
qf_list_T *qfl = &qi->qf_lists[qf_idx];
|
qf_list_T *qfl = qf_get_list(qi, qf_idx);
|
||||||
qfline_T *old_last = NULL;
|
qfline_T *old_last = NULL;
|
||||||
int retval = OK;
|
int retval = OK;
|
||||||
|
|
||||||
@@ -5582,8 +5579,8 @@ static int qf_add_entries(qf_info_T *qi, int qf_idx, list_T *list,
|
|||||||
// make place for a new list
|
// make place for a new list
|
||||||
qf_new_list(qi, title);
|
qf_new_list(qi, title);
|
||||||
qf_idx = qi->qf_curlist;
|
qf_idx = qi->qf_curlist;
|
||||||
qfl = &qi->qf_lists[qf_idx];
|
qfl = qf_get_list(qi, qf_idx);
|
||||||
} else if (action == 'a' && !qf_list_empty(qi, qf_idx)) {
|
} else if (action == 'a' && !qf_list_empty(qfl)) {
|
||||||
// Adding to existing list, use last entry.
|
// Adding to existing list, use last entry.
|
||||||
old_last = qfl->qf_last;
|
old_last = qfl->qf_last;
|
||||||
} else if (action == 'r') {
|
} else if (action == 'r') {
|
||||||
@@ -5601,7 +5598,7 @@ static int qf_add_entries(qf_info_T *qi, int qf_idx, list_T *list,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = qf_add_entry_from_dict(qi, qf_idx, d, li == tv_list_first(list));
|
retval = qf_add_entry_from_dict(qfl, d, li == tv_list_first(list));
|
||||||
if (retval == FAIL) {
|
if (retval == FAIL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -5615,7 +5612,7 @@ static int qf_add_entries(qf_info_T *qi, int qf_idx, list_T *list,
|
|||||||
}
|
}
|
||||||
if (action != 'a') {
|
if (action != 'a') {
|
||||||
qfl->qf_ptr = qfl->qf_start;
|
qfl->qf_ptr = qfl->qf_start;
|
||||||
if (!qf_list_empty(qi, qf_idx)) {
|
if (!qf_list_empty(qfl)) {
|
||||||
qfl->qf_index = 1;
|
qfl->qf_index = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5686,7 +5683,7 @@ static int qf_setprop_title(qf_info_T *qi, int qf_idx, const dict_T *what,
|
|||||||
const dictitem_T *di)
|
const dictitem_T *di)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
qf_list_T *qfl = &qi->qf_lists[qf_idx];
|
qf_list_T *qfl = qf_get_list(qi, qf_idx);
|
||||||
if (di->di_tv.v_type != VAR_STRING) {
|
if (di->di_tv.v_type != VAR_STRING) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@@ -5790,7 +5787,7 @@ static int qf_set_properties(qf_info_T *qi, const dict_T *what, int action,
|
|||||||
qf_idx = qi->qf_curlist;
|
qf_idx = qi->qf_curlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
qfl = &qi->qf_lists[qf_idx];
|
qfl = qf_get_list(qi, qf_idx);
|
||||||
if ((di = tv_dict_find(what, S_LEN("title"))) != NULL) {
|
if ((di = tv_dict_find(what, S_LEN("title"))) != NULL) {
|
||||||
retval = qf_setprop_title(qi, qf_idx, what, di);
|
retval = qf_setprop_title(qi, qf_idx, what, di);
|
||||||
}
|
}
|
||||||
@@ -6205,8 +6202,7 @@ static void hgr_search_file(
|
|||||||
line[--l] = NUL;
|
line[--l] = NUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qf_add_entry(qi,
|
if (qf_add_entry(qf_get_curlist(qi),
|
||||||
qi->qf_curlist,
|
|
||||||
NULL, // dir
|
NULL, // dir
|
||||||
fname,
|
fname,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -6356,7 +6352,7 @@ void ex_helpgrep(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Jump to first match.
|
// Jump to first match.
|
||||||
if (!qf_list_empty(qi, qi->qf_curlist)) {
|
if (!qf_list_empty(qf_get_curlist(qi))) {
|
||||||
qf_jump(qi, 0, 0, false);
|
qf_jump(qi, 0, 0, false);
|
||||||
} else {
|
} else {
|
||||||
EMSG2(_(e_nomatch2), eap->arg);
|
EMSG2(_(e_nomatch2), eap->arg);
|
||||||
|
Reference in New Issue
Block a user