summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-07-16 16:54:24 +0200
committerBram Moolenaar <Bram@vim.org>2016-07-16 16:54:24 +0200
commitf6acffbe83e622542d9fdf3066f51933e46e4954 (patch)
tree70664752ad37e9760fa63ce2c0f432896022628c
parenta06ecab7a5159e744448ace731036f0dc5f87dd4 (diff)
downloadvim-git-f6acffbe83e622542d9fdf3066f51933e46e4954.tar.gz
patch 7.4.2049v7.4.2049
Problem: There is no way to get a list of the error lists. Solution: Add ":chistory" and ":lhistory".
-rw-r--r--src/ex_cmds.h6
-rw-r--r--src/ex_docmd.c1
-rw-r--r--src/message.c23
-rw-r--r--src/proto/quickfix.pro1
-rw-r--r--src/quickfix.c50
-rw-r--r--src/testdir/test_quickfix.vim24
-rw-r--r--src/version.c2
7 files changed, 94 insertions, 13 deletions
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index f57adc0db..eb6eb25b7 100644
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -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),
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 853a5977f..41a228d22 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -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
diff --git a/src/message.c b/src/message.c
index 954152850..72cd79ea6 100644
--- a/src/message.c
+++ b/src/message.c
@@ -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;
}
}
diff --git a/src/proto/quickfix.pro b/src/proto/quickfix.pro
index a2b6b76cb..02c2d9831 100644
--- a/src/proto/quickfix.pro
+++ b/src/proto/quickfix.pro
@@ -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);
diff --git a/src/quickfix.c b/src/quickfix.c
index 689897554..1fb47a009 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -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".
*/
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 39f788e4f..9fbef15f8 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 8b41fe9d9..f0df84806 100644
--- a/src/version.c
+++ b/src/version.c
@@ -759,6 +759,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2049,
+/**/
2048,
/**/
2047,