-*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
|: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
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('\n');
sprintf((char *)IObuff, "%c%6d ", i == idx ? '>' : ' ',
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('\n')
+ 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('\n')
+ 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('\n')
+ 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('\n')
+ 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()