]> granicus.if.org Git - vim/commitdiff
patch 7.4.2049 v7.4.2049
authorBram Moolenaar <Bram@vim.org>
Sat, 16 Jul 2016 14:54:24 +0000 (16:54 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 16 Jul 2016 14:54:24 +0000 (16:54 +0200)
Problem:    There is no way to get a list of the error lists.
Solution:   Add ":chistory" and ":lhistory".

src/ex_cmds.h
src/ex_docmd.c
src/message.c
src/proto/quickfix.pro
src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index f57adc0db39766f36bc674e3d5e19a98c81dda69..eb6eb25b76c6a934ea0aa2e990cdb522111f661e 100644 (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),
index 853a5977f55bc215e1145c0dcc4709434698057a..41a228d22906584e80443bd0cb8ec9313e95a7ad 100644 (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
index 954152850c5ce944f22333b77f390062094d364f..72cd79ea6eb4056c8052d39837611b3de35aeedb 100644 (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;
     }
 }
 
index a2b6b76cbcca6a2d4d75d5cff9597e7398432444..02c2d9831b48f4aa3d06dfb5d9b36520fccd186c 100644 (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);
index 689897554cdb4de11891c13370380ec06d139145..1fb47a00982b513813bda894c00b7370f9f6a63d 100644 (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".
  */
index 39f788e4f304973f5ddf2230c4fee9c2db72c1b5..9fbef15f8f688e588c85dc4856572e362aa68b02 100644 (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
index 8b41fe9d9212d0ac6400ba89826fbef7adadd7e3..f0df8480662829bc466a0d1230a83899d8b73cbb 100644 (file)
@@ -758,6 +758,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2049,
 /**/
     2048,
 /**/