blob: 6d09b6f30a3352f71ac81f4492a733745e0335dd [file] [log] [blame]
Christian Brabandt95886662023-11-12 16:55:01 +01001" Test for the matchparen plugin
2
3if !has('gui_running') && has('unix')
4 set term=ansi
5endif
6
7source view_util.vim
8source check.vim
9source screendump.vim
10
11" Test for scrolling that modifies buffer during visual block
12func Test_visual_block_scroll()
13 CheckScreendump
14
15 let lines =<< trim END
16 source $VIMRUNTIME/plugin/matchparen.vim
17 set scrolloff=1
18 call setline(1, ['a', 'b', 'c', 'd', 'e', '', '{', '}', '{', 'f', 'g', '}'])
19 call cursor(5, 1)
20 END
21
22 let filename = 'Xvisualblockmodifiedscroll'
23 call writefile(lines, filename, 'D')
24
25 let buf = RunVimInTerminal('-S '.filename, #{rows: 7})
26 call term_sendkeys(buf, "V\<C-D>\<C-D>")
27
28 call VerifyScreenDump(buf, 'Test_display_visual_block_scroll', {})
29
30 call StopVimInTerminal(buf)
31endfunc
32
33" Test for clearing paren highlight when switching buffers
34func Test_matchparen_clear_highlight()
35 CheckScreendump
36
37 let lines =<< trim END
38 source $VIMRUNTIME/plugin/matchparen.vim
39 set hidden
40 call setline(1, ['()'])
41 normal 0
42
43 func OtherBuffer()
44 enew
45 exe "normal iaa\<Esc>0"
46 endfunc
47 END
48 call writefile(lines, 'XMatchparenClear', 'D')
49 let buf = RunVimInTerminal('-S XMatchparenClear', #{rows: 5})
50 call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_1', {})
51
52 call term_sendkeys(buf, ":call OtherBuffer()\<CR>:\<Esc>")
53 call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_2', {})
54
55 call term_sendkeys(buf, "\<C-^>:\<Esc>")
56 call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_1', {})
57
58 call term_sendkeys(buf, "\<C-^>:\<Esc>")
59 call VerifyScreenDump(buf, 'Test_matchparen_clear_highlight_2', {})
60
61 call StopVimInTerminal(buf)
62endfunc
63
64" Test for scrolling that modifies buffer during visual block
65func Test_matchparen_pum_clear()
66 CheckScreendump
67
68 let lines =<< trim END
69 source $VIMRUNTIME/plugin/matchparen.vim
70 set completeopt=menuone
71 call setline(1, ['aa', 'aaa', 'aaaa', '(a)'])
72 call cursor(4, 3)
73 END
74
75 let filename = 'Xmatchparen'
76 call writefile(lines, filename, 'D')
77
78 let buf = RunVimInTerminal('-S '.filename, #{rows: 10})
79 call term_sendkeys(buf, "i\<C-N>\<C-N>")
80
81 call VerifyScreenDump(buf, 'Test_matchparen_pum_clear_1', {})
82
83 call StopVimInTerminal(buf)
84endfunc
85
86
87" vim: shiftwidth=2 sts=2 expandtab