Mercurial > vim
annotate src/testdir/test_hlsearch.vim @ 32397:f9d4988a86ef v9.0.1530
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Commit: https://github.com/vim/vim/commit/aa6ba308a1498dc8da04d1d30ec0470018bf782a
Author: Luuk van Baal <luukvbaal@gmail.com>
Date: Tue May 9 16:01:17 2023 +0100
patch 9.0.1530: cursor moves to wrong line when 'foldmethod' is "diff"
Problem: Cursor moves to wrong line when 'foldmethod' is "diff". (Rick
Howe)
Solution: Adjust logic for scrolling. (Luuk van Baal, closes #12364,
closes #12218)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 09 May 2023 17:15:03 +0200 |
parents | 19648eb383d9 |
children | 57e589d18e7d |
rev | line source |
---|---|
10145
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test for v:hlsearch |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
3 source check.vim |
31932
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
4 source screendump.vim |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
5 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14662
diff
changeset
|
6 func Test_hlsearch() |
10145
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 new |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 call setline(1, repeat(['aaa'], 10)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 set hlsearch nolazyredraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 " redraw is needed to make hlsearch highlight the matches |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 exe "normal! /aaa\<CR>" | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 let r1 = screenattr(1, 1) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 nohlsearch | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call assert_notequal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 let v:hlsearch=1 | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 call assert_equal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 let v:hlsearch=0 | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 call assert_notequal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 set hlsearch | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 call assert_equal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 let v:hlsearch=0 | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 call assert_notequal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 exe "normal! n" | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 call assert_equal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 let v:hlsearch=0 | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 call assert_notequal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 exe "normal! /\<CR>" | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 call assert_equal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 set nohls |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 exe "normal! /\<CR>" | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 call assert_notequal(r1, screenattr(1,1)) |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
32 call assert_fails('let v:hlsearch=[]', 'E745:') |
10145
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 call garbagecollect(1) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 call getchar(1) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 enew! |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14662
diff
changeset
|
36 endfunc |
11523
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
37 |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
38 func Test_hlsearch_hangs() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
39 CheckFunction reltimefloat |
11523
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
40 |
29224
ca46658481cf
patch 8.2.5131: timeout implementation is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
29216
diff
changeset
|
41 " So, it turns out that Windows 7 implements TimerQueue timers differently |
29071
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
42 " and they can expire *before* the requested time has elapsed. So allow for |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
43 " the timeout occurring after 80 ms (5 * 16 (the typical clock tick)). |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
44 if has("win32") |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
45 let min_timeout = 0.08 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
46 else |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
47 let min_timeout = 0.1 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
48 endif |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
49 |
11525
14b6b79d685b
patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents:
11523
diff
changeset
|
50 " This pattern takes a long time to match, it should timeout. |
11527
ac20f71e8aa4
patch 8.0.0646: the hlsearch test fails on fast systems
Christian Brabandt <cb@256bit.org>
parents:
11525
diff
changeset
|
51 new |
ac20f71e8aa4
patch 8.0.0646: the hlsearch test fails on fast systems
Christian Brabandt <cb@256bit.org>
parents:
11525
diff
changeset
|
52 call setline(1, ['aaa', repeat('abc ', 1000), 'ccc']) |
11523
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
53 let start = reltime() |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
54 set hlsearch nolazyredraw redrawtime=101 |
11525
14b6b79d685b
patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents:
11523
diff
changeset
|
55 let @/ = '\%#=1a*.*X\@<=b*' |
11523
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
56 redraw |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
57 let elapsed = reltimefloat(reltime(start)) |
29216
32f3b86352e6
patch 8.2.5127: using assert_true() does not show value on failure
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
58 call assert_inrange(min_timeout, 1.0, elapsed) |
11523
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
59 set nohlsearch redrawtime& |
11527
ac20f71e8aa4
patch 8.0.0646: the hlsearch test fails on fast systems
Christian Brabandt <cb@256bit.org>
parents:
11525
diff
changeset
|
60 bwipe! |
11523
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
61 endfunc |
14662
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
62 |
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
63 func Test_hlsearch_eol_highlight() |
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
64 new |
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
65 call append(1, repeat([''], 9)) |
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
66 set hlsearch nolazyredraw |
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
67 exe "normal! /$\<CR>" | redraw |
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
68 let attr = screenattr(1, 1) |
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
69 for row in range(2, 10) |
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
70 call assert_equal(attr, screenattr(row, 1), 'in line ' . row) |
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
71 endfor |
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
72 set nohlsearch |
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
73 bwipe! |
04c168a6d998
patch 8.1.0344: 'hlsearch' highlighting has a gap after /$
Christian Brabandt <cb@256bit.org>
parents:
11527
diff
changeset
|
74 endfunc |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
75 |
31932
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
76 func Test_hlsearch_Ctrl_R() |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
77 CheckRunVimInTerminal |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
78 |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
79 let lines =<< trim END |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
80 set incsearch hlsearch |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
81 let @" = "text" |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
82 put |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
83 END |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
84 call writefile(lines, 'XhlsearchCtrlR', 'D') |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
85 let buf = RunVimInTerminal('-S XhlsearchCtrlR', #{rows: 6, cols: 60}) |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
86 |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
87 call term_sendkeys(buf, "/\<C-R>\<C-R>\"") |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
88 call VerifyScreenDump(buf, 'Test_hlsearch_ctrlr_1', {}) |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
89 |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
90 call term_sendkeys(buf, "\<Esc>") |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
91 call StopVimInTerminal(buf) |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
92 endfunc |
19648eb383d9
patch 9.0.1298: inserting register on the cmdline does not trigger incsearch
Bram Moolenaar <Bram@vim.org>
parents:
29224
diff
changeset
|
93 |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
94 " vim: shiftwidth=2 sts=2 expandtab |