0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 7.4.2049

Problem:    There is no way to get a list of the error lists.
Solution:   Add ":chistory" and ":lhistory".
This commit is contained in:
Bram Moolenaar 2016-07-16 16:54:24 +02:00
parent a06ecab7a5
commit f6acffbe83
7 changed files with 94 additions and 13 deletions

View File

@ -310,6 +310,9 @@ EX(CMD_checkpath, "checkpath", ex_checkpath,
EX(CMD_checktime, "checktime", ex_checktime,
RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR,
ADDR_LINES),
EX(CMD_chistory, "chistory", qf_history,
TRLBAR,
ADDR_LINES),
EX(CMD_clist, "clist", qf_list,
BANG|EXTRA|TRLBAR|CMDWIN,
ADDR_LINES),
@ -784,6 +787,9 @@ EX(CMD_lgrepadd, "lgrepadd", ex_make,
EX(CMD_lhelpgrep, "lhelpgrep", ex_helpgrep,
EXTRA|NOTRLCOM|NEEDARG,
ADDR_LINES),
EX(CMD_lhistory, "lhistory", qf_history,
TRLBAR,
ADDR_LINES),
EX(CMD_ll, "ll", ex_cc,
RANGE|NOTADR|COUNT|TRLBAR|BANG,
ADDR_LINES),

View File

@ -122,6 +122,7 @@ static int getargopt(exarg_T *eap);
# define ex_cfile ex_ni
# define qf_list ex_ni
# define qf_age ex_ni
# define qf_history ex_ni
# define ex_helpgrep ex_ni
# define ex_vimgrep ex_ni
#endif

View File

@ -313,9 +313,25 @@ trunc_string(
len += n;
}
/* Set the middle and copy the last part. */
if (e + 3 < buflen)
if (i <= e + 3)
{
/* text fits without truncating */
if (s != buf)
{
len = STRLEN(s);
if (len >= buflen)
len = buflen - 1;
len = len - e + 1;
if (len < 1)
buf[e - 1] = NUL;
else
mch_memmove(buf + e, s + e, len);
}
}
else if (e + 3 < buflen)
{
/* set the middle and copy the last part */
mch_memmove(buf + e, "...", (size_t)3);
len = (int)STRLEN(s + i) + 1;
if (len >= buflen - e - 3)
@ -325,7 +341,8 @@ trunc_string(
}
else
{
buf[e - 1] = NUL; /* make sure it is truncated */
/* can't fit in the "...", just truncate it */
buf[e - 1] = NUL;
}
}

View File

@ -5,6 +5,7 @@ void copy_loclist(win_T *from, win_T *to);
void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit);
void qf_list(exarg_T *eap);
void qf_age(exarg_T *eap);
void qf_history(exarg_T *eap);
void qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long amount_after);
void ex_cwindow(exarg_T *eap);
void ex_cclose(exarg_T *eap);

View File

@ -120,7 +120,6 @@ static void qf_new_list(qf_info_T *qi, char_u *qf_title);
static void ll_free_all(qf_info_T **pqi);
static int qf_add_entry(qf_info_T *qi, char_u *dir, char_u *fname, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid);
static qf_info_T *ll_new_list(void);
static void qf_msg(qf_info_T *qi);
static void qf_free(qf_info_T *qi, int idx);
static char_u *qf_types(int, int);
static int qf_get_fnum(qf_info_T *qi, char_u *, char_u *);
@ -2544,6 +2543,29 @@ qf_fmt_text(char_u *text, char_u *buf, int bufsize)
buf[i] = NUL;
}
static void
qf_msg(qf_info_T *qi, int which, char *lead)
{
char *title = (char *)qi->qf_lists[which].qf_title;
int count = qi->qf_lists[which].qf_count;
char_u buf[IOSIZE];
vim_snprintf((char *)buf, IOSIZE, _("%serror list %d of %d; %d errors "),
lead,
which + 1,
qi->qf_listcount,
count);
if (title != NULL)
{
while (STRLEN(buf) < 34)
STRCAT(buf, " ");
STRCAT(buf, title);
}
trunc_string(buf, buf, Columns - 1, IOSIZE);
msg(buf);
}
/*
* ":colder [count]": Up in the quickfix stack.
* ":cnewer [count]": Down in the quickfix stack.
@ -2591,20 +2613,28 @@ qf_age(exarg_T *eap)
++qi->qf_curlist;
}
}
qf_msg(qi);
}
static void
qf_msg(qf_info_T *qi)
{
smsg((char_u *)_("error list %d of %d; %d errors"),
qi->qf_curlist + 1, qi->qf_listcount,
qi->qf_lists[qi->qf_curlist].qf_count);
qf_msg(qi, qi->qf_curlist, "");
#ifdef FEAT_WINDOWS
qf_update_buffer(qi, NULL);
#endif
}
void
qf_history(exarg_T *eap)
{
qf_info_T *qi = &ql_info;
int i;
if (eap->cmdidx == CMD_lhistory)
qi = GET_LOC_LIST(curwin);
if (qi == NULL || (qi->qf_listcount == 0
&& qi->qf_lists[qi->qf_curlist].qf_count == 0))
MSG(_("No entries"));
else
for (i = 0; i < qi->qf_listcount; ++i)
qf_msg(qi, i, i == qi->qf_curlist ? "> " : " ");
}
/*
* Free error list "idx".
*/

View File

@ -1438,3 +1438,27 @@ function Test_cbottom()
call XbottomTests('c')
call XbottomTests('l')
endfunction
function HistoryTest(cchar)
call s:setup_commands(a:cchar)
call assert_fails(a:cchar . 'older 99', 'E380:')
" clear all lists after the first one, then replace the first one.
call g:Xsetlist([])
Xolder
let entry = {'filename': 'foo', 'lnum': 42}
call g:Xsetlist([entry], 'r')
call g:Xsetlist([entry, entry])
call g:Xsetlist([entry, entry, entry])
let res = split(execute(a:cchar . 'hist'), "\n")
call assert_equal(3, len(res))
let common = 'errors :set' . (a:cchar == 'c' ? 'qf' : 'loc') . 'list()'
call assert_equal(' error list 1 of 3; 1 ' . common, res[0])
call assert_equal(' error list 2 of 3; 2 ' . common, res[1])
call assert_equal('> error list 3 of 3; 3 ' . common, res[2])
endfunc
func Test_history()
call HistoryTest('c')
call HistoryTest('l')
endfunc

View File

@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2049,
/**/
2048,
/**/