patch 9.1.0439: Cannot filter the history

Commit: 
https://github.com/vim/vim/commit/42a5b5a6d0d05255b9c464abe71f29c7677b5833
Author: Christian Brabandt <c...@256bit.org>
Date:   Fri May 24 07:39:34 2024 +0200

    patch 9.1.0439: Cannot filter the history
    
    Problem:  Cannot filter the history
    Solution: Implement :filter :history
    
    closes: #14835
    
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index 0aa5c7431..889ad40ba 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -1,4 +1,4 @@
-*various.txt*   For Vim version 9.1.  Last change: 2023 Sep 27
+*various.txt*   For Vim version 9.1.  Last change: 2024 May 23
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -608,6 +608,7 @@ N  *+X11*           Unix only: can restore window title 
|X11|
                           |:command|    - filter by command name
                           |:files|      - filter by file name
                           |:highlight|  - filter by highlight group
+                          |:history|    - filter by history commands
                           |:jumps|      - filter by file name
                           |:let|        - filter by variable name
                           |:list|       - filter whole line
diff --git a/src/cmdhist.c b/src/cmdhist.c
index 7cdcee6b8..684c08e70 100644
--- a/src/cmdhist.c
+++ b/src/cmdhist.c
@@ -767,7 +767,8 @@ ex_history(exarg_T *eap)
                if (i == hislen)
                    i = 0;
                if (hist[i].hisstr != NULL
-                       && hist[i].hisnum >= j && hist[i].hisnum <= k)
+                       && hist[i].hisnum >= j && hist[i].hisnum <= k
+                       && !message_filtered(hist[i].hisstr))
                {
                    msg_putchar('
');
                    sprintf((char *)IObuff, "%c%6d  ", i == idx ? '>' : ' ',
diff --git a/src/testdir/test_history.vim b/src/testdir/test_history.vim
index 19490f252..b288abc3f 100644
--- a/src/testdir/test_history.vim
+++ b/src/testdir/test_history.vim
@@ -96,6 +96,60 @@ function Test_History()
   call assert_fails('history xyz', 'E488:')
   call assert_fails('history ,abc', 'E488:')
   call assert_fails('call histdel(":", "\%(")', 'E53:')
+
+  " Test for filtering the history list
+  let hist_filter = execute(':filter /_\d/ :history all')->split('
')
+  call assert_equal(20, len(hist_filter))
+  let expected = ['      #  cmd history',
+               \ '      2  text_2',
+               \ '      3  text_3',
+               \ '>     4  text_4',
+               \ '      #  search history',
+               \ '      2  text_2',
+               \ '      3  text_3',
+               \ '>     4  text_4',
+               \ '      #  expr history',
+               \ '      2  text_2',
+               \ '      3  text_3',
+               \ '>     4  text_4',
+               \ '      #  input history',
+               \ '      2  text_2',
+               \ '      3  text_3',
+               \ '>     4  text_4',
+               \ '      #  debug history',
+               \ '      2  text_2',
+               \ '      3  text_3',
+               \ '>     4  text_4']
+  call assert_equal(expected, hist_filter)
+
+  let cmds = {'c': 'cmd', 's': 'search', 'e': 'expr', 'i': 'input', 'd': 
'debug'}
+  for h in sort(keys(cmds))
+    " find some items
+    let hist_filter = execute(':filter /_\d/ :history ' .. h)->split('
')
+    call assert_equal(4, len(hist_filter))
+
+    let expected = ['      #  ' .. cmds[h] .. ' history',
+               \ '      2  text_2',
+               \ '      3  text_3',
+               \ '>     4  text_4']
+    call assert_equal(expected, hist_filter)
+
+    " Search for an item that is not there
+    let hist_filter = execute(':filter /XXXX/ :history ' .. h)->split('
')
+    call assert_equal(1, len(hist_filter))
+
+    let expected = ['      #  ' .. cmds[h] .. ' history']
+    call assert_equal(expected, hist_filter)
+
+    " Invert the filter condition, find non-matches
+    let hist_filter = execute(':filter! /_3$/ :history ' .. h)->split('
')
+    call assert_equal(3, len(hist_filter))
+
+    let expected = ['      #  ' .. cmds[h] .. ' history',
+               \ '      2  text_2',
+               \ '>     4  text_4']
+    call assert_equal(expected, hist_filter)
+  endfor
 endfunction
 
 function Test_history_truncates_long_entry()
diff --git a/src/version.c b/src/version.c
index ac1a1f4f3..f6a7db8ae 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    439,
 /**/
     438,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1sANjv-003nA0-JS%40256bit.org.

Raspunde prin e-mail lui