Mercurial > vim
diff src/testdir/test_filter_cmd.vim @ 14968:c5ec5ddbe814 v8.1.0495
patch 8.1.0495: :filter only supports some commands
commit https://github.com/vim/vim/commit/f86db78fed78541cefdb706e4779ce5ae9ca7820
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 25 13:31:37 2018 +0200
patch 8.1.0495: :filter only supports some commands
Problem: :filter only supports some commands.
Solution: Add :filter support for more commands. (Marcin Szamotulski,
closes #2856)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 25 Oct 2018 13:45:05 +0200 |
parents | d4777be849d0 |
children | 5b06b642fbee |
line wrap: on
line diff
--- a/src/testdir/test_filter_cmd.vim +++ b/src/testdir/test_filter_cmd.vim @@ -87,3 +87,43 @@ func Test_filter_cmd_with_filter() call assert_equal('a|b', out) set shelltemp& endfunction + +func Test_filter_commands() + let g:test_filter_a = 1 + let b:test_filter_b = 2 + let test_filter_c = 3 + + " Test filtering :let command + let res = split(execute("filter /^test_filter/ let"), "\n") + call assert_equal(["test_filter_a #1"], res) + + let res = split(execute("filter /\\v^(b:)?test_filter/ let"), "\n") + call assert_equal(["test_filter_a #1", "b:test_filter_b #2"], res) + + unlet g:test_filter_a + unlet b:test_filter_b + unlet test_filter_c + + " Test filtering :set command + let res = join(split(execute("filter /^help/ set"), "\n")[1:], " ") + call assert_match('^\s*helplang=\w*$', res) + + " Test filtering :llist command + call setloclist(0, [{"filename": "/path/vim.c"}, {"filename": "/path/vim.h"}, {"module": "Main.Test"}]) + let res = split(execute("filter /\\.c$/ llist"), "\n") + call assert_equal([" 1 /path/vim.c: "], res) + + let res = split(execute("filter /\\.Test$/ llist"), "\n") + call assert_equal([" 3 Main.Test: "], res) + + " Test filtering :jump command + e file.c + e file.h + e file.hs + let res = split(execute("filter /\.c$/ jumps"), "\n")[1:] + call assert_equal([" 2 1 0 file.c", ">"], res) + + bwipe file.c + bwipe file.h + bwipe file.hs +endfunc