aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlonerover <pathfinder1644@yahoo.com>2017-01-17 15:36:00 +0800
committerlonerover <pathfinder1644@yahoo.com>2017-01-19 10:11:53 +0800
commit1a06a3948861b11a9bae0b044f0342fc2190584d (patch)
tree9bce1f43e4cf4ff3d25604d008377e504e765477 /src
parentd3b4764dc137e0f6f2c219244e00fba92a64a384 (diff)
downloadrneovim-1a06a3948861b11a9bae0b044f0342fc2190584d.tar.gz
rneovim-1a06a3948861b11a9bae0b044f0342fc2190584d.tar.bz2
rneovim-1a06a3948861b11a9bae0b044f0342fc2190584d.zip
vim-patch:7.4.2049
Problem: There is no way to get a list of the error lists. Solution: Add ":chistory" and ":lhistory". https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_cmds.lua12
-rw-r--r--src/nvim/message.c21
-rw-r--r--src/nvim/quickfix.c45
-rw-r--r--src/nvim/testdir/test_quickfix.vim24
-rw-r--r--src/nvim/version.c2
5 files changed, 94 insertions, 10 deletions
diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua
index 88095602ba..5f81306fc1 100644
--- a/src/nvim/ex_cmds.lua
+++ b/src/nvim/ex_cmds.lua
@@ -462,6 +462,12 @@ return {
func='ex_checktime',
},
{
+ command='chistory',
+ flags=bit.bor(TRLBAR),
+ addr_type=ADDR_LINES,
+ func='qf_history',
+ },
+ {
command='clist',
flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN),
addr_type=ADDR_LINES,
@@ -1400,6 +1406,12 @@ return {
func='ex_helpgrep',
},
{
+ command='lhistory',
+ flags=bit.bor(TRLBAR),
+ addr_type=ADDR_LINES,
+ func='qf_history',
+ },
+ {
command='ll',
flags=bit.bor(RANGE, NOTADR, COUNT, TRLBAR, BANG),
addr_type=ADDR_LINES,
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 2f8feda6ec..749fa8a706 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -297,8 +297,22 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen)
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 {
+ memmove(buf + e, s + e, len);
+ }
+ }
+ } else if (e + 3 < buflen) {
+ // set the middle and copy the last part
memmove(buf + e, "...", (size_t)3);
len = (int)STRLEN(s + i) + 1;
if (len >= buflen - e - 3)
@@ -306,7 +320,8 @@ void trunc_string(char_u *s, char_u *buf, int room, int buflen)
memmove(buf + e + 3, s + i, len);
buf[e + 3 + len - 1] = NUL;
} 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/nvim/quickfix.c b/src/nvim/quickfix.c
index 33a84660c1..2fa0fb9840 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -2105,6 +2105,28 @@ static void 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.
@@ -2145,15 +2167,26 @@ void qf_age(exarg_T *eap)
++qi->qf_curlist;
}
}
- qf_msg(qi);
+ qf_msg(qi, qi->qf_curlist, "");
+ qf_update_buffer(qi, NULL);
}
-static void qf_msg(qf_info_T *qi)
+void qf_history(exarg_T *eap)
{
- smsg(_("error list %d of %d; %d errors"),
- qi->qf_curlist + 1, qi->qf_listcount,
- qi->qf_lists[qi->qf_curlist].qf_count);
- qf_update_buffer(qi, NULL);
+ 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 ? "> " : " ");
+ }
+ }
}
/*
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index f30902b915..17f0bde6d3 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -1420,3 +1420,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/nvim/version.c b/src/nvim/version.c
index 3dfc32fc6d..98cfdd1b4a 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -391,7 +391,7 @@ static int included_patches[] = {
// 2052 NA
// 2051,
// 2050,
- // 2049,
+ 2049,
// 2048 NA
// 2047,
// 2046,