Mercurial > vim
comparison src/testdir/test_filter_cmd.vim @ 9980:b222552cf0c4 v7.4.2263
commit https://github.com/vim/vim/commit/d29459baa61819e59961804ed258efac5733ec70
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 26 22:29:11 2016 +0200
patch 7.4.2263
Problem: :filter does not work for many commands. Can only get matching
messages.
Solution: Make :filter work for :command, :map, :list, :number and :print.
Make ":filter!" show non-matching lines.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 26 Aug 2016 22:30:07 +0200 |
parents | e975914c17e9 |
children | 4b152b5f414f |
comparison
equal
deleted
inserted
replaced
9979:782064bf4bc1 | 9980:b222552cf0c4 |
---|---|
2 | 2 |
3 func Test_filter() | 3 func Test_filter() |
4 edit Xdoesnotmatch | 4 edit Xdoesnotmatch |
5 edit Xwillmatch | 5 edit Xwillmatch |
6 call assert_equal('"Xwillmatch"', substitute(execute('filter willma ls'), '[^"]*\(".*"\)[^"]*', '\1', '')) | 6 call assert_equal('"Xwillmatch"', substitute(execute('filter willma ls'), '[^"]*\(".*"\)[^"]*', '\1', '')) |
7 bwipe Xdoesnotmatch | |
8 bwipe Xwillmatch | |
9 | |
10 new | |
11 call setline(1, ['foo1', 'foo2', 'foo3', 'foo4', 'foo5']) | |
12 call assert_equal("\nfoo2\nfoo4", execute('filter /foo[24]/ 1,$print')) | |
13 call assert_equal("\n 2 foo2\n 4 foo4", execute('filter /foo[24]/ 1,$number')) | |
14 call assert_equal("\nfoo2$\nfoo4$", execute('filter /foo[24]/ 1,$list')) | |
15 | |
16 call assert_equal("\nfoo1$\nfoo3$\nfoo5$", execute('filter! /foo[24]/ 1,$list')) | |
17 bwipe! | |
18 | |
19 command XTryThis echo 'this' | |
20 command XTryThat echo 'that' | |
21 command XDoThat echo 'that' | |
22 let lines = split(execute('filter XTry command'), "\n") | |
23 call assert_equal(3, len(lines)) | |
24 call assert_match("XTryThat", lines[1]) | |
25 call assert_match("XTryThis", lines[2]) | |
26 delcommand XTryThis | |
27 delcommand XTryThat | |
28 delcommand XDoThat | |
29 | |
30 map f1 the first key | |
31 map f2 the second key | |
32 map f3 not a key | |
33 let lines = split(execute('filter the map f'), "\n") | |
34 call assert_equal(2, len(lines)) | |
35 call assert_match("f2", lines[0]) | |
36 call assert_match("f1", lines[1]) | |
37 unmap f1 | |
38 unmap f2 | |
39 unmap f3 | |
7 endfunc | 40 endfunc |
8 | 41 |
9 func Test_filter_fails() | 42 func Test_filter_fails() |
10 call assert_fails('filter', 'E471:') | 43 call assert_fails('filter', 'E471:') |
11 call assert_fails('filter pat', 'E476:') | 44 call assert_fails('filter pat', 'E476:') |
12 call assert_fails('filter /pat', 'E476:') | 45 call assert_fails('filter /pat', 'E476:') |
13 call assert_fails('filter /pat/', 'E476:') | 46 call assert_fails('filter /pat/', 'E476:') |
14 call assert_fails('filter /pat/ asdf', 'E492:') | 47 call assert_fails('filter /pat/ asdf', 'E492:') |
48 | |
49 call assert_fails('filter!', 'E471:') | |
50 call assert_fails('filter! pat', 'E476:') | |
51 call assert_fails('filter! /pat', 'E476:') | |
52 call assert_fails('filter! /pat/', 'E476:') | |
53 call assert_fails('filter! /pat/ asdf', 'E492:') | |
15 endfunc | 54 endfunc |