Mercurial > vim
annotate src/testdir/test_search_stat.vim @ 20712:f65c7bc846b2
Added tag v8.2.0909 for changeset d91b8d1e5198a181f1fc9fcc6a6614ba584599dd
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 05 Jun 2020 22:45:05 +0200 |
parents | 1260b27535b5 |
children | ce36225c9bed |
rev | line source |
---|---|
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Tests for search_stats, when "S" is not in 'shortmess' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
17968
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
3 source check.vim |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
4 source screendump.vim |
16560
8d0ea09e2d81
patch 8.1.1283: delaying half a second after the top-bot message
Bram Moolenaar <Bram@vim.org>
parents:
16533
diff
changeset
|
5 |
17968
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
6 func Test_search_stat() |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 new |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 set shortmess-=S |
16570
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
9 " Append 50 lines with text to search for, "foobar" appears 20 times |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 |
20647
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
12 call cursor(1, 1) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
13 |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
14 " searchcount() returns an empty dictionary when previous pattern was not set |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
15 call assert_equal({}, searchcount(#{pattern: ''})) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
16 " but setting @/ should also work (even 'n' nor 'N' was executed) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
17 " recompute the count when the last position is different. |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
18 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
19 \ #{current: 1, exact_match: 1, total: 40, incomplete: 0, maxcount: 99}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
20 \ searchcount(#{pattern: 'foo'})) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
21 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
22 \ #{current: 0, exact_match: 0, total: 10, incomplete: 0, maxcount: 99}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
23 \ searchcount(#{pattern: 'fooooobar'})) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
24 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
25 \ #{current: 0, exact_match: 0, total: 10, incomplete: 0, maxcount: 99}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
26 \ searchcount(#{pattern: 'fooooobar', pos: [2, 1, 0]})) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
27 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
28 \ #{current: 1, exact_match: 1, total: 10, incomplete: 0, maxcount: 99}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
29 \ searchcount(#{pattern: 'fooooobar', pos: [3, 1, 0]})) |
20667
a126f643d566
patch 8.2.0887: searchcount().exact_match is 1 right after a match
Bram Moolenaar <Bram@vim.org>
parents:
20661
diff
changeset
|
30 " on last char of match |
a126f643d566
patch 8.2.0887: searchcount().exact_match is 1 right after a match
Bram Moolenaar <Bram@vim.org>
parents:
20661
diff
changeset
|
31 call assert_equal( |
a126f643d566
patch 8.2.0887: searchcount().exact_match is 1 right after a match
Bram Moolenaar <Bram@vim.org>
parents:
20661
diff
changeset
|
32 \ #{current: 1, exact_match: 1, total: 10, incomplete: 0, maxcount: 99}, |
a126f643d566
patch 8.2.0887: searchcount().exact_match is 1 right after a match
Bram Moolenaar <Bram@vim.org>
parents:
20661
diff
changeset
|
33 \ searchcount(#{pattern: 'fooooobar', pos: [3, 9, 0]})) |
a126f643d566
patch 8.2.0887: searchcount().exact_match is 1 right after a match
Bram Moolenaar <Bram@vim.org>
parents:
20661
diff
changeset
|
34 " on char after match |
a126f643d566
patch 8.2.0887: searchcount().exact_match is 1 right after a match
Bram Moolenaar <Bram@vim.org>
parents:
20661
diff
changeset
|
35 call assert_equal( |
a126f643d566
patch 8.2.0887: searchcount().exact_match is 1 right after a match
Bram Moolenaar <Bram@vim.org>
parents:
20661
diff
changeset
|
36 \ #{current: 1, exact_match: 0, total: 10, incomplete: 0, maxcount: 99}, |
a126f643d566
patch 8.2.0887: searchcount().exact_match is 1 right after a match
Bram Moolenaar <Bram@vim.org>
parents:
20661
diff
changeset
|
37 \ searchcount(#{pattern: 'fooooobar', pos: [3, 10, 0]})) |
20647
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
38 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
39 \ #{current: 1, exact_match: 0, total: 10, incomplete: 0, maxcount: 99}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
40 \ searchcount(#{pattern: 'fooooobar', pos: [4, 1, 0]})) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
41 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
42 \ #{current: 1, exact_match: 0, total: 2, incomplete: 2, maxcount: 1}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
43 \ searchcount(#{pattern: 'fooooobar', pos: [4, 1, 0], maxcount: 1})) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
44 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
45 \ #{current: 0, exact_match: 0, total: 2, incomplete: 2, maxcount: 1}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
46 \ searchcount(#{pattern: 'fooooobar', maxcount: 1})) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
47 |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
48 " match at second line |
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
49 let messages_before = execute('messages') |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 let @/ = 'fo*\(bar\?\)\?' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 let g:a = execute(':unsilent :norm! n') |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 let stat = '\[2/50\]' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 let pat = escape(@/, '()*?'). '\s\+' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 call assert_match(pat .. stat, g:a) |
20647
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
55 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
56 \ #{current: 2, exact_match: 1, total: 50, incomplete: 0, maxcount: 99}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
57 \ searchcount(#{recompute: 0})) |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
58 " didn't get added to message history |
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
59 call assert_equal(messages_before, execute('messages')) |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
61 " Match at last line |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 call cursor(line('$')-2, 1) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 let g:a = execute(':unsilent :norm! n') |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 let stat = '\[50/50\]' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 call assert_match(pat .. stat, g:a) |
20647
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
66 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
67 \ #{current: 50, exact_match: 1, total: 50, incomplete: 0, maxcount: 99}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
68 \ searchcount(#{recompute: 0})) |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
70 " No search stat |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 set shortmess+=S |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 call cursor(1, 1) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 let stat = '\[2/50\]' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 let g:a = execute(':unsilent :norm! n') |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 call assert_notmatch(pat .. stat, g:a) |
20647
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
76 call writefile(getline(1, '$'), 'sample.txt') |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
77 " n does not update search stat |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
78 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
79 \ #{current: 50, exact_match: 1, total: 50, incomplete: 0, maxcount: 99}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
80 \ searchcount(#{recompute: 0})) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
81 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
82 \ #{current: 2, exact_match: 1, total: 50, incomplete: 0, maxcount: 99}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
83 \ searchcount(#{recompute: v:true})) |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 set shortmess-=S |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
86 " Many matches |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 call cursor(line('$')-2, 1) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 let @/ = '.' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 let pat = escape(@/, '()*?'). '\s\+' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 let g:a = execute(':unsilent :norm! n') |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 let stat = '\[>99/>99\]' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 call assert_match(pat .. stat, g:a) |
20647
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
93 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
94 \ #{current: 100, exact_match: 0, total: 100, incomplete: 2, maxcount: 99}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
95 \ searchcount(#{recompute: 0})) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
96 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
97 \ #{current: 272, exact_match: 1, total: 280, incomplete: 0, maxcount: 0}, |
20661
c7843f009ecf
patch 8.2.0884: searchcount() test fails on slower systems
Bram Moolenaar <Bram@vim.org>
parents:
20647
diff
changeset
|
98 \ searchcount(#{recompute: v:true, maxcount: 0, timeout: 200})) |
20647
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
99 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
100 \ #{current: 1, exact_match: 1, total: 280, incomplete: 0, maxcount: 0}, |
20661
c7843f009ecf
patch 8.2.0884: searchcount() test fails on slower systems
Bram Moolenaar <Bram@vim.org>
parents:
20647
diff
changeset
|
101 \ searchcount(#{recompute: 1, maxcount: 0, pos: [1, 1, 0], timeout: 200})) |
16696
b1756c303066
patch 8.1.1350: "W" for wrapping not shown when more than 99 matches
Bram Moolenaar <Bram@vim.org>
parents:
16570
diff
changeset
|
102 call cursor(line('$'), 1) |
b1756c303066
patch 8.1.1350: "W" for wrapping not shown when more than 99 matches
Bram Moolenaar <Bram@vim.org>
parents:
16570
diff
changeset
|
103 let g:a = execute(':unsilent :norm! n') |
17992
a9c54c20295c
patch 8.1.1992: the search stat moves when wrapping at the end of the buffer
Bram Moolenaar <Bram@vim.org>
parents:
17968
diff
changeset
|
104 let stat = 'W \[1/>99\]' |
16696
b1756c303066
patch 8.1.1350: "W" for wrapping not shown when more than 99 matches
Bram Moolenaar <Bram@vim.org>
parents:
16570
diff
changeset
|
105 call assert_match(pat .. stat, g:a) |
20647
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
106 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
107 \ #{current: 1, exact_match: 1, total: 100, incomplete: 2, maxcount: 99}, |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
108 \ searchcount(#{recompute: 0})) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
109 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
110 \ #{current: 1, exact_match: 1, total: 280, incomplete: 0, maxcount: 0}, |
20661
c7843f009ecf
patch 8.2.0884: searchcount() test fails on slower systems
Bram Moolenaar <Bram@vim.org>
parents:
20647
diff
changeset
|
111 \ searchcount(#{recompute: 1, maxcount: 0, timeout: 200})) |
20647
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
112 call assert_equal( |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
113 \ #{current: 271, exact_match: 1, total: 280, incomplete: 0, maxcount: 0}, |
20661
c7843f009ecf
patch 8.2.0884: searchcount() test fails on slower systems
Bram Moolenaar <Bram@vim.org>
parents:
20647
diff
changeset
|
114 \ searchcount(#{recompute: 1, maxcount: 0, pos: [line('$')-2, 1, 0], timeout: 200})) |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
116 " Many matches |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 call cursor(1, 1) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 let g:a = execute(':unsilent :norm! n') |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 let stat = '\[2/>99\]' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 call assert_match(pat .. stat, g:a) |
16696
b1756c303066
patch 8.1.1350: "W" for wrapping not shown when more than 99 matches
Bram Moolenaar <Bram@vim.org>
parents:
16570
diff
changeset
|
121 call cursor(1, 1) |
b1756c303066
patch 8.1.1350: "W" for wrapping not shown when more than 99 matches
Bram Moolenaar <Bram@vim.org>
parents:
16570
diff
changeset
|
122 let g:a = execute(':unsilent :norm! N') |
17992
a9c54c20295c
patch 8.1.1992: the search stat moves when wrapping at the end of the buffer
Bram Moolenaar <Bram@vim.org>
parents:
17968
diff
changeset
|
123 let stat = 'W \[>99/>99\]' |
16696
b1756c303066
patch 8.1.1350: "W" for wrapping not shown when more than 99 matches
Bram Moolenaar <Bram@vim.org>
parents:
16570
diff
changeset
|
124 call assert_match(pat .. stat, g:a) |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
126 " right-left |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 if exists("+rightleft") |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 set rl |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 call cursor(1,1) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 let @/ = 'foobar' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 let pat = 'raboof/\s\+' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 let g:a = execute(':unsilent :norm! n') |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 let stat = '\[20/2\]' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 call assert_match(pat .. stat, g:a) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 set norl |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 endif |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
138 " right-left bottom |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 if exists("+rightleft") |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 set rl |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 call cursor('$',1) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 let pat = 'raboof?\s\+' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 let g:a = execute(':unsilent :norm! N') |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 let stat = '\[20/20\]' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 call assert_match(pat .. stat, g:a) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 set norl |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 endif |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
149 " right-left back at top |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 if exists("+rightleft") |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 set rl |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 call cursor('$',1) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 let pat = 'raboof/\s\+' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 let g:a = execute(':unsilent :norm! n') |
17992
a9c54c20295c
patch 8.1.1992: the search stat moves when wrapping at the end of the buffer
Bram Moolenaar <Bram@vim.org>
parents:
17968
diff
changeset
|
155 let stat = 'W \[20/1\]' |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 call assert_match(pat .. stat, g:a) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 call assert_match('search hit BOTTOM, continuing at TOP', g:a) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 set norl |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 endif |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
161 " normal, back at bottom |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 call cursor(1,1) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 let @/ = 'foobar' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 let pat = '?foobar\s\+' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 let g:a = execute(':unsilent :norm! N') |
17992
a9c54c20295c
patch 8.1.1992: the search stat moves when wrapping at the end of the buffer
Bram Moolenaar <Bram@vim.org>
parents:
17968
diff
changeset
|
166 let stat = 'W \[20/20\]' |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 call assert_match(pat .. stat, g:a) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 call assert_match('search hit TOP, continuing at BOTTOM', g:a) |
17992
a9c54c20295c
patch 8.1.1992: the search stat moves when wrapping at the end of the buffer
Bram Moolenaar <Bram@vim.org>
parents:
17968
diff
changeset
|
169 call assert_match('W \[20/20\]', Screenline(&lines)) |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
171 " normal, no match |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 call cursor(1,1) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 let @/ = 'zzzzzz' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 let g:a = '' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 try |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 let g:a = execute(':unsilent :norm! n') |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 catch /^Vim\%((\a\+)\)\=:E486/ |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 let stat = '' |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 " error message is not redir'ed to g:a, it is empty |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 call assert_true(empty(g:a)) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 catch |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 call assert_false(1) |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 endtry |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 |
16776
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
185 " with count |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
186 call cursor(1, 1) |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
187 let @/ = 'fo*\(bar\?\)\?' |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
188 let g:a = execute(':unsilent :norm! 2n') |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
189 let stat = '\[3/50\]' |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
190 let pat = escape(@/, '()*?'). '\s\+' |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
191 call assert_match(pat .. stat, g:a) |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
192 let g:a = execute(':unsilent :norm! 2n') |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
193 let stat = '\[5/50\]' |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
194 call assert_match(pat .. stat, g:a) |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
195 |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
196 " with offset |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
197 call cursor(1, 1) |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
198 call feedkeys("/fo*\\(bar\\?\\)\\?/+1\<cr>", 'tx') |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
199 let g:a = execute(':unsilent :norm! n') |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
200 let stat = '\[5/50\]' |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
201 let pat = escape(@/ .. '/+1', '()*?'). '\s\+' |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
202 call assert_match(pat .. stat, g:a) |
7d4c814a8554
patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents:
16746
diff
changeset
|
203 |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
204 " normal, n comes from a mapping |
16570
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
205 " Need to move over more than 64 lines to trigger char_avail(. |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
206 nnoremap n nzv |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
207 call cursor(1,1) |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
208 call append(50, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
209 call setline(2, 'find this') |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
210 call setline(70, 'find this') |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
211 let @/ = 'find this' |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
212 let pat = '/find this\s\+' |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
213 let g:a = execute(':unsilent :norm n') |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
214 " g:a will contain several lines |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
215 let g:b = split(g:a, "\n")[-1] |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
216 let stat = '\[1/2\]' |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
217 call assert_match(pat .. stat, g:b) |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
218 unmap n |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
219 |
16746
73ff6357da5b
patch 8.1.1375: without "TS" in 'shortmess' get a hit-enter prompt often
Bram Moolenaar <Bram@vim.org>
parents:
16696
diff
changeset
|
220 " normal, but silent |
16570
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
221 call cursor(1,1) |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
222 let @/ = 'find this' |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
223 let pat = '/find this\s\+' |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
224 let g:a = execute(':norm! n') |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
225 let stat = '\[1/2\]' |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
226 call assert_notmatch(pat .. stat, g:a) |
2c2f5f0173c1
patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents:
16560
diff
changeset
|
227 |
17948
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
228 " normal, n comes from a silent mapping |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
229 " First test a normal mapping, then a silent mapping |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
230 call cursor(1,1) |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
231 nnoremap n n |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
232 let @/ = 'find this' |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
233 let pat = '/find this\s\+' |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
234 let g:a = execute(':unsilent :norm n') |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
235 let g:b = split(g:a, "\n")[-1] |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
236 let stat = '\[1/2\]' |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
237 call assert_match(pat .. stat, g:b) |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
238 nnoremap <silent> n n |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
239 call cursor(1,1) |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
240 let g:a = execute(':unsilent :norm n') |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
241 let g:b = split(g:a, "\n")[-1] |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
242 let stat = '\[1/2\]' |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
243 call assert_notmatch(pat .. stat, g:b) |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
244 call assert_match(stat, g:b) |
17968
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
245 " Test that the message is not truncated |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
246 " it would insert '...' into the output. |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
247 call assert_match('^\s\+' .. stat, g:b) |
17948
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
248 unmap n |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
249 |
20647
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
250 " Time out |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
251 %delete _ |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
252 call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 100000)) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
253 call cursor(1, 1) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
254 call assert_equal(1, searchcount(#{pattern: 'foo', maxcount: 0, timeout: 1}).incomplete) |
8a2b86a39ef4
patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents:
20573
diff
changeset
|
255 |
17948
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
256 " Clean up |
c77a41ea0365
patch 8.1.1970: search stat space wrong, no test for 8.1.1965
Bram Moolenaar <Bram@vim.org>
parents:
16776
diff
changeset
|
257 set shortmess+=S |
16533
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 " close the window |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 bwipe! |
5e25171e0e75
patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 endfunc |
17968
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
261 |
20685
4c66962d322b
patch 8.2.0896: crash when calling searchcount() with a string
Bram Moolenaar <Bram@vim.org>
parents:
20667
diff
changeset
|
262 func Test_searchcount_fails() |
4c66962d322b
patch 8.2.0896: crash when calling searchcount() with a string
Bram Moolenaar <Bram@vim.org>
parents:
20667
diff
changeset
|
263 call assert_fails('echo searchcount("boo!")', 'E715:') |
4c66962d322b
patch 8.2.0896: crash when calling searchcount() with a string
Bram Moolenaar <Bram@vim.org>
parents:
20667
diff
changeset
|
264 endfunc |
4c66962d322b
patch 8.2.0896: crash when calling searchcount() with a string
Bram Moolenaar <Bram@vim.org>
parents:
20667
diff
changeset
|
265 |
20697
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
266 func Test_searchcount_in_statusline() |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
267 CheckScreendump |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
268 |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
269 let lines =<< trim END |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
270 set shortmess-=S |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
271 call append(0, 'this is something') |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
272 function TestSearchCount() abort |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
273 let search_count = searchcount() |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
274 if !empty(search_count) |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
275 return '[' . search_count.current . '/' . search_count.total . ']' |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
276 else |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
277 return '' |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
278 endif |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
279 endfunction |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
280 set hlsearch |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
281 set laststatus=2 statusline+=%{TestSearchCount()} |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
282 END |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
283 call writefile(lines, 'Xsearchstatusline') |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
284 let buf = RunVimInTerminal('-S Xsearchstatusline', #{rows: 10}) |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
285 call TermWait(buf) |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
286 call term_sendkeys(buf, "/something") |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
287 call VerifyScreenDump(buf, 'Test_searchstat_4', {}) |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
288 |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
289 call term_sendkeys(buf, "\<Esc>") |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
290 call StopVimInTerminal(buf) |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
291 call delete('Xsearchstatusline') |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
292 endfunc |
1260b27535b5
patch 8.2.0902: using searchcount() in 'statusline' causes an error
Bram Moolenaar <Bram@vim.org>
parents:
20685
diff
changeset
|
293 |
20573
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
294 func Test_search_stat_foldopen() |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
295 CheckScreendump |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
296 |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
297 let lines =<< trim END |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
298 set shortmess-=S |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
299 setl foldenable foldmethod=indent foldopen-=search |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
300 call append(0, ['if', "\tfoo", "\tfoo", 'endif']) |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
301 let @/ = 'foo' |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
302 call cursor(1,1) |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
303 norm n |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
304 END |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
305 call writefile(lines, 'Xsearchstat1') |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
306 |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
307 let buf = RunVimInTerminal('-S Xsearchstat1', #{rows: 10}) |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
308 call TermWait(buf) |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
309 call VerifyScreenDump(buf, 'Test_searchstat_3', {}) |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
310 |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
311 call term_sendkeys(buf, "n") |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
312 call TermWait(buf) |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
313 call VerifyScreenDump(buf, 'Test_searchstat_3', {}) |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
314 |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
315 call term_sendkeys(buf, "n") |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
316 call TermWait(buf) |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
317 call VerifyScreenDump(buf, 'Test_searchstat_3', {}) |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
318 |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
319 call StopVimInTerminal(buf) |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
320 call delete('Xsearchstat1') |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
321 endfunc |
00fff78a929a
patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
322 |
17968
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
323 func! Test_search_stat_screendump() |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
324 CheckScreendump |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
325 |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
326 let lines =<< trim END |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
327 set shortmess-=S |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
328 " Append 50 lines with text to search for, "foobar" appears 20 times |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
329 call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 20)) |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
330 call setline(2, 'find this') |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
331 call setline(70, 'find this') |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
332 nnoremap n n |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
333 let @/ = 'find this' |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
334 call cursor(1,1) |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
335 norm n |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
336 END |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
337 call writefile(lines, 'Xsearchstat') |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
338 let buf = RunVimInTerminal('-S Xsearchstat', #{rows: 10}) |
19954
c087099e9163
patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents:
17992
diff
changeset
|
339 call TermWait(buf) |
17968
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
340 call VerifyScreenDump(buf, 'Test_searchstat_1', {}) |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
341 |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
342 call term_sendkeys(buf, ":nnoremap <silent> n n\<cr>") |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
343 call term_sendkeys(buf, "gg0n") |
19954
c087099e9163
patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents:
17992
diff
changeset
|
344 call TermWait(buf) |
17968
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
345 call VerifyScreenDump(buf, 'Test_searchstat_2', {}) |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
346 |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
347 call StopVimInTerminal(buf) |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
348 call delete('Xsearchstat') |
22ddc0ee65e7
patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents:
17948
diff
changeset
|
349 endfunc |