]> granicus.if.org Git - vim/commitdiff
patch 8.1.1281: cannot specify a count with :chistory v8.1.1281
authorBram Moolenaar <Bram@vim.org>
Sun, 5 May 2019 19:00:26 +0000 (21:00 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 5 May 2019 19:00:26 +0000 (21:00 +0200)
Problem:    Cannot specify a count with :chistory.
Solution:   Add a count to :chistory and :lhistory. (Yegappan Lakshmanan,
            closes #4344)

runtime/doc/quickfix.txt
src/ex_cmds.h
src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index 6d9b3425090473cdc034ade21c1f12055b6d29c3..bae2ee93232c7b6985234e42d0a2002031912da0 100644 (file)
@@ -139,8 +139,8 @@ processing a quickfix or location list command, it will be aborted.
 :[count]lab[ove]       Same as ":cabove", except the location list for the
                        current window is used instead of the quickfix list.
 
-                                                       *:cbe* *:cbelow*
-:[count]cbe[low]       Go to the [count] error below the current line in the
+                                                       *:cbel* *:cbelow*
+:[count]cbel[ow]       Go to the [count] error below the current line in the
                        current buffer.  If [count] is omitted, then 1 is
                        used.  If there are no errors, then an error message
                        is displayed.  Assumes that the entries in a quickfix
@@ -164,8 +164,8 @@ processing a quickfix or location list command, it will be aborted.
                        number of entries before the current position, then
                        the first error in the file is selected.
 
-                                                       *:lbef* *:lbefore*
-:[count]lbef[ore]      Same as ":cbefore", except the location list for the
+                                                       *:lbe* *:lbefore*
+:[count]lbe[fore]      Same as ":cbefore", except the location list for the
                        current window is used instead of the quickfix list.
 
                                                        *:caf* *:cafter*
@@ -536,6 +536,29 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
                                etc.
 <                      Otherwise it works the same as `:ldo`.
 
+FILTERING A QUICKFIX OR LOCATION LIST:
+                                   *cfilter-plugin* *:Cfilter* *:Lfilter*
+If you have too many entries in a quickfix list, you can use the cfilter
+plugin to reduce the number of entries.  Load the plugin with: >
+
+    packadd cfilter
+
+Then you can use the following commands to filter a quickfix/location list: >
+
+    :Cfilter[!] /{pat}/
+    :Lfilter[!] /{pat}/
+
+The |:Cfilter| command creates a new quickfix list from the entries matching
+{pat} in the current quickfix list. {pat} is a Vim |regular-expression|
+pattern. Both the file name and the text of the entries are matched against
+{pat}. If the optional ! is supplied, then the entries not matching {pat} are
+used. The pattern can be optionally enclosed using one of the following
+characters: ', ", /. If the pattern is empty, then the last used search
+pattern is used.
+
+The |:Lfilter| command does the same as |:Cfilter| but operates on the current
+location list.
+
 =============================================================================
 2. The error window                                    *quickfix-window*
 
@@ -822,14 +845,19 @@ lists.  They set one of the existing error lists as the current one.
                        the current window instead of the quickfix list.
 
                                                *:chistory* *:chi*
-:chi[story]            Show the list of error lists.  The current list is
+:[count]chi[story]     Show the list of error lists.  The current list is
                        marked with ">".  The output looks like:
                                  error list 1 of 3; 43 errors ~
                                > error list 2 of 3; 0 errors ~
                                  error list 3 of 3; 15 errors ~
 
+                       When [count] is given, then the count'th quickfix
+                       list is made the current list. Example: >
+                               " Make the 4th quickfix list current
+                               :4chistory
+<
                                                *:lhistory* *:lhi*
-:lhi[story]            Show the list of location lists, otherwise like
+:[count]lhi[story]     Show the list of location lists, otherwise like
                        `:chistory`.
 
 When adding a new error list, it becomes the current list.
@@ -1641,22 +1669,6 @@ The backslashes before the pipe character are required to avoid it to be
 recognized as a command separator.  The backslash before each space is
 required for the set command.
 
-                                   *cfilter-plugin* *:Cfilter* *:Lfilter*
-If you have too many matching messages, you can use the cfilter plugin to
-reduce the number of entries.  Load the plugin with: >
-   packadd cfilter
-
-Then you can use these command: >
-   :Cfilter[!] /{pat}/
-   :Lfilter[!] /{pat}/
-
-:Cfilter creates a new quickfix list from entries matching {pat} in the
-current quickfix list. Both the file name and the text of the entries are
-matched against {pat}. If ! is supplied, then entries not matching {pat} are
-used.
-
-:Lfilter does the same as :Cfilter but operates on the current location list.
-
 =============================================================================
 8. The directory stack                         *quickfix-directory-stack*
 
index 9e420b3fd16e01e608173280e775b52b05257362..37577f7b30e7482fd56c9ee6e41cc4ccb1c9aafd 100644 (file)
@@ -336,8 +336,8 @@ EX(CMD_checktime,   "checktime",    ex_checktime,
                        RANGE|BUFNAME|COUNT|EXTRA|TRLBAR,
                        ADDR_OTHER),
 EX(CMD_chistory,       "chistory",     qf_history,
-                       TRLBAR,
-                       ADDR_NONE),
+                       RANGE|COUNT|TRLBAR,
+                       ADDR_UNSIGNED),
 EX(CMD_clist,          "clist",        qf_list,
                        BANG|EXTRA|TRLBAR|CMDWIN,
                        ADDR_NONE),
@@ -828,8 +828,8 @@ EX(CMD_lhelpgrep,   "lhelpgrep",    ex_helpgrep,
                        EXTRA|NOTRLCOM|NEEDARG,
                        ADDR_NONE),
 EX(CMD_lhistory,       "lhistory",     qf_history,
-                       TRLBAR,
-                       ADDR_NONE),
+                       RANGE|COUNT|TRLBAR,
+                       ADDR_UNSIGNED),
 EX(CMD_ll,             "ll",           ex_cc,
                        RANGE|COUNT|TRLBAR|BANG,
                        ADDR_QUICKFIX),
index b4497ae754821110303f84d6229ffb5b3ad0dcd6..61576505a92f8ba01d083397f056d922ee657b31 100644 (file)
@@ -3742,6 +3742,27 @@ qf_history(exarg_T *eap)
     qf_info_T  *qi = qf_cmd_get_stack(eap, FALSE);
     int                i;
 
+    if (eap->addr_count > 0)
+    {
+       if (qi == NULL)
+       {
+           emsg(_(e_loclist));
+           return;
+       }
+
+       // Jump to the specified quickfix list
+       if (eap->line2 > 0 && eap->line2 <= qi->qf_listcount)
+       {
+           qi->qf_curlist = eap->line2 - 1;
+           qf_msg(qi, qi->qf_curlist, "");
+           qf_update_buffer(qi, NULL);
+       }
+       else
+           emsg(_(e_invrange));
+
+       return;
+    }
+
     if (qf_stack_empty(qi))
        msg(_("No entries"));
     else
index ae3aec5222340e26ebccc5edb25eacaf761da1d4..54c10ad6a22ff95fc630ec859fc39b9153d6ff71 100644 (file)
@@ -1831,9 +1831,23 @@ func HistoryTest(cchar)
   call assert_equal('  error list 2 of 3; 2 ' . common, res[1])
   call assert_equal('> error list 3 of 3; 3 ' . common, res[2])
 
+  " Test for changing the quickfix lists
+  call assert_equal(3, g:Xgetlist({'nr' : 0}).nr)
+  exe '1' . a:cchar . 'hist'
+  call assert_equal(1, g:Xgetlist({'nr' : 0}).nr)
+  exe '3' . a:cchar . 'hist'
+  call assert_equal(3, g:Xgetlist({'nr' : 0}).nr)
+  call assert_fails('-2' . a:cchar . 'hist', 'E16:')
+  call assert_fails('4' . a:cchar . 'hist', 'E16:')
+
   call g:Xsetlist([], 'f')
   let l = split(execute(a:cchar . 'hist'), "\n")
   call assert_equal('No entries', l[0])
+  if a:cchar == 'c'
+    call assert_fails('4chist', 'E16:')
+  else
+    call assert_fails('4lhist', 'E776:')
+  endif
 
   " An empty list should still show the stack history
   call g:Xsetlist([])
index 0ba9dd13c5b726e29a4fae81840ef6e3eaf27c66..f137b8356c98a49ffe0750c8a5ede64e8da009e8 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1281,
 /**/
     1280,
 /**/