annotate src/testdir/test_search_stat.vim @ 20647:8a2b86a39ef4 v8.2.0877

patch 8.2.0877: cannot get the search statistics Commit: https://github.com/vim/vim/commit/e8f5ec0d30b629d7166f0ad03434065d8bc822df Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jun 1 17:28:35 2020 +0200 patch 8.2.0877: cannot get the search statistics Problem: Cannot get the search statistics. Solution: Add the searchcount() function. (Fujiwara Takuya, closes https://github.com/vim/vim/issues/4446)
author Bram Moolenaar <Bram@vim.org>
date Mon, 01 Jun 2020 17:30:04 +0200
parents 00fff78a929a
children c7843f009ecf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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]}))
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
30 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
31 \ #{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
32 \ 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
33 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
34 \ #{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
35 \ 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
36 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
37 \ #{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
38 \ searchcount(#{pattern: 'fooooobar', maxcount: 1}))
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
39
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
40 " 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
41 let messages_before = execute('messages')
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 let @/ = 'fo*\(bar\?\)\?'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 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
44 let stat = '\[2/50\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 let pat = escape(@/, '()*?'). '\s\+'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 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
47 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
48 \ #{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
49 \ 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
50 " 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
51 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
52
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
53 " Match at last line
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 call cursor(line('$')-2, 1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 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
56 let stat = '\[50/50\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 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
58 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
59 \ #{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
60 \ searchcount(#{recompute: 0}))
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61
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
62 " No search stat
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 set shortmess+=S
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 call cursor(1, 1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 let stat = '\[2/50\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 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
67 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
68 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
69 " 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
70 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
71 \ #{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
72 \ searchcount(#{recompute: 0}))
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
73 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
74 \ #{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
75 \ searchcount(#{recompute: v:true}))
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 set shortmess-=S
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77
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
78 " Many matches
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 call cursor(line('$')-2, 1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 let @/ = '.'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 let pat = escape(@/, '()*?'). '\s\+'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 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
83 let stat = '\[>99/>99\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 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
85 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
86 \ #{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
87 \ searchcount(#{recompute: 0}))
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
88 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
89 \ #{current: 272, exact_match: 1, total: 280, incomplete: 0, maxcount: 0},
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
90 \ searchcount(#{recompute: v:true, maxcount: 0}))
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
91 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
92 \ #{current: 1, exact_match: 1, total: 280, incomplete: 0, maxcount: 0},
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
93 \ searchcount(#{recompute: 1, maxcount: 0, pos: [1, 1, 0]}))
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
94 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
95 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
96 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
97 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
98 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
99 \ #{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
100 \ searchcount(#{recompute: 0}))
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
101 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
102 \ #{current: 1, exact_match: 1, total: 280, incomplete: 0, maxcount: 0},
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
103 \ searchcount(#{recompute: 1, maxcount: 0}))
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
104 call assert_equal(
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
105 \ #{current: 271, exact_match: 1, total: 280, incomplete: 0, maxcount: 0},
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
106 \ searchcount(#{recompute: 1, maxcount: 0, pos: [line('$')-2, 1, 0]}))
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107
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
108 " Many matches
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 call cursor(1, 1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 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
111 let stat = '\[2/>99\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 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
113 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
114 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
115 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
116 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
117
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
118 " right-left
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 if exists("+rightleft")
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 set rl
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 call cursor(1,1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 let @/ = 'foobar'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 let pat = 'raboof/\s\+'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 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
125 let stat = '\[20/2\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 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
127 set norl
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 endif
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129
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
130 " right-left bottom
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 if exists("+rightleft")
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 set rl
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 call cursor('$',1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 let pat = 'raboof?\s\+'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 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
136 let stat = '\[20/20\]'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 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
138 set norl
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 endif
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140
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
141 " right-left back at top
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 if exists("+rightleft")
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 set rl
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 call cursor('$',1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 let pat = 'raboof/\s\+'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 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
147 let stat = 'W \[20/1\]'
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 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
149 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
150 set norl
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 endif
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152
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
153 " normal, back at bottom
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 call cursor(1,1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 let @/ = 'foobar'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 let pat = '?foobar\s\+'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 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
158 let stat = 'W \[20/20\]'
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 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
160 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
161 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
162
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
163 " normal, no match
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 call cursor(1,1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 let @/ = 'zzzzzz'
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 let g:a = ''
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 try
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 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
169 catch /^Vim\%((\a\+)\)\=:E486/
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 let stat = ''
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 " 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
172 call assert_true(empty(g:a))
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 catch
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 call assert_false(1)
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 endtry
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176
16776
7d4c814a8554 patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents: 16746
diff changeset
177 " 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
178 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
179 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
180 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
181 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
182 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
183 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
184 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
185 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
186 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
187
7d4c814a8554 patch 8.1.1390: search stats are off when using count or offset
Bram Moolenaar <Bram@vim.org>
parents: 16746
diff changeset
188 " 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
189 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
190 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
191 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
192 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
193 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
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
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
196 " 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
197 " 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
198 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
199 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
200 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
201 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
202 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
203 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
204 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
205 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
206 " 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
207 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
208 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
209 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
210 unmap n
2c2f5f0173c1 patch 8.1.1288: search stats don't show for mapped command
Bram Moolenaar <Bram@vim.org>
parents: 16560
diff changeset
211
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
212 " 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
213 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
214 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
215 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
216 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
217 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
218 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
219
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
220 " 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
221 " 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
222 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
223 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
224 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
225 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
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 " 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
238 " 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
239 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
240 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
241
20647
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
242 " Time out
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
243 %delete _
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
244 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
245 call cursor(1, 1)
8a2b86a39ef4 patch 8.2.0877: cannot get the search statistics
Bram Moolenaar <Bram@vim.org>
parents: 20573
diff changeset
246 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
247
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 " 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
249 set shortmess+=S
16533
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 " close the window
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 bwipe!
5e25171e0e75 patch 8.1.1270: cannot see current match position
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 endfunc
17968
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
253
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
254 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
255 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
256
00fff78a929a patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
257 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
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 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
266
00fff78a929a patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
267 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
268 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
269 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
270
00fff78a929a patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
271 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
272 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
273 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
274
00fff78a929a patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
275 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
276 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
277 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
278
00fff78a929a patch 8.2.0840: search match count wrong when only match is in fold
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
279 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
280 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
281 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
282
17968
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
283 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
284 CheckScreendump
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
285
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
286 let lines =<< trim END
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
287 set shortmess-=S
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
288 " 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
289 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
290 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
291 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
292 nnoremap n n
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
293 let @/ = 'find this'
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
294 call cursor(1,1)
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
295 norm n
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
296 END
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
297 call writefile(lines, 'Xsearchstat')
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
298 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
299 call TermWait(buf)
17968
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
300 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
301
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
302 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
303 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
304 call TermWait(buf)
17968
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
305 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
306
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
307 call StopVimInTerminal(buf)
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
308 call delete('Xsearchstat')
22ddc0ee65e7 patch 8.1.1980: fix for search stat not tested
Bram Moolenaar <Bram@vim.org>
parents: 17948
diff changeset
309 endfunc