2024-04-20 08:44:13 -07:00
|
|
|
|
local n = require('test.functional.testnvim')()
|
2023-11-12 19:47:12 -07:00
|
|
|
|
local Screen = require('test.functional.ui.screen')
|
2024-04-20 08:44:13 -07:00
|
|
|
|
|
|
|
|
|
local clear = n.clear
|
|
|
|
|
local exec = n.exec
|
|
|
|
|
local feed = n.feed
|
2023-11-12 19:47:12 -07:00
|
|
|
|
|
|
|
|
|
describe('matchparen', function()
|
|
|
|
|
before_each(clear)
|
|
|
|
|
|
|
|
|
|
-- oldtest: Test_visual_block_scroll()
|
|
|
|
|
it('redraws properly after scrolling with scrolloff=1', function()
|
|
|
|
|
local screen = Screen.new(30, 7)
|
|
|
|
|
exec([[
|
|
|
|
|
source $VIMRUNTIME/plugin/matchparen.vim
|
|
|
|
|
set scrolloff=1
|
|
|
|
|
call setline(1, ['a', 'b', 'c', 'd', 'e', '', '{', '}', '{', 'f', 'g', '}'])
|
|
|
|
|
call cursor(5, 1)
|
|
|
|
|
]])
|
|
|
|
|
|
2024-04-02 11:58:49 -07:00
|
|
|
|
feed('V<c-d><c-d>')
|
2023-11-12 19:47:12 -07:00
|
|
|
|
screen:expect([[
|
2024-03-27 02:35:50 -07:00
|
|
|
|
{17:{} |
|
|
|
|
|
{17:}} |
|
|
|
|
|
{17:{} |
|
|
|
|
|
{17:f} |
|
2023-11-12 19:47:12 -07:00
|
|
|
|
^g |
|
|
|
|
|
} |
|
2024-03-27 02:35:50 -07:00
|
|
|
|
{5:-- VISUAL LINE --} |
|
2023-11-12 19:47:12 -07:00
|
|
|
|
]])
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
-- oldtest: Test_matchparen_clear_highlight()
|
|
|
|
|
it('matchparen highlight is cleared when switching buffer', function()
|
|
|
|
|
local screen = Screen.new(20, 5)
|
2024-11-08 03:45:55 -07:00
|
|
|
|
screen:add_extra_attr_ids {
|
|
|
|
|
[100] = { background = Screen.colors.Cyan1 },
|
|
|
|
|
}
|
2023-11-12 19:47:12 -07:00
|
|
|
|
|
|
|
|
|
local screen1 = [[
|
2024-11-08 03:45:55 -07:00
|
|
|
|
{100:^()} |
|
|
|
|
|
{1:~ }|*3
|
2023-11-12 19:47:12 -07:00
|
|
|
|
|
|
|
|
|
|
]]
|
|
|
|
|
local screen2 = [[
|
|
|
|
|
^aa |
|
2024-11-08 03:45:55 -07:00
|
|
|
|
{1:~ }|*3
|
2023-11-12 19:47:12 -07:00
|
|
|
|
|
|
|
|
|
|
]]
|
|
|
|
|
|
|
|
|
|
exec([[
|
|
|
|
|
source $VIMRUNTIME/plugin/matchparen.vim
|
|
|
|
|
set hidden
|
|
|
|
|
call setline(1, ['()'])
|
|
|
|
|
normal 0
|
2024-03-11 16:19:47 -07:00
|
|
|
|
|
|
|
|
|
func OtherBuffer()
|
|
|
|
|
enew
|
|
|
|
|
exe "normal iaa\<Esc>0"
|
|
|
|
|
endfunc
|
2023-11-12 19:47:12 -07:00
|
|
|
|
]])
|
|
|
|
|
screen:expect(screen1)
|
|
|
|
|
|
2024-03-11 16:19:47 -07:00
|
|
|
|
exec('call OtherBuffer()')
|
2023-11-12 19:47:12 -07:00
|
|
|
|
screen:expect(screen2)
|
|
|
|
|
|
|
|
|
|
feed('<C-^>')
|
|
|
|
|
screen:expect(screen1)
|
|
|
|
|
|
|
|
|
|
feed('<C-^>')
|
|
|
|
|
screen:expect(screen2)
|
|
|
|
|
end)
|
|
|
|
|
|
2024-03-11 16:19:47 -07:00
|
|
|
|
-- oldtest: Test_matchparen_win_execute()
|
|
|
|
|
it('matchparen highlight when switching buffer in win_execute()', function()
|
|
|
|
|
local screen = Screen.new(20, 5)
|
2024-11-08 03:45:55 -07:00
|
|
|
|
screen:add_extra_attr_ids {
|
|
|
|
|
[100] = { background = Screen.colors.Cyan1 },
|
|
|
|
|
}
|
2024-03-11 16:19:47 -07:00
|
|
|
|
|
|
|
|
|
exec([[
|
|
|
|
|
source $VIMRUNTIME/plugin/matchparen.vim
|
|
|
|
|
let s:win = win_getid()
|
|
|
|
|
call setline(1, '{}')
|
|
|
|
|
split
|
|
|
|
|
|
|
|
|
|
func SwitchBuf()
|
|
|
|
|
call win_execute(s:win, 'enew | buffer #')
|
|
|
|
|
endfunc
|
|
|
|
|
]])
|
|
|
|
|
screen:expect([[
|
2024-11-08 03:45:55 -07:00
|
|
|
|
{100:^{}} |
|
2024-03-11 16:19:47 -07:00
|
|
|
|
{3:[No Name] [+] }|
|
2024-11-08 03:45:55 -07:00
|
|
|
|
{} |
|
|
|
|
|
{2:[No Name] [+] }|
|
2024-03-11 16:19:47 -07:00
|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
|
|
|
|
|
-- Switching buffer away and back shouldn't change matchparen highlight.
|
|
|
|
|
exec('call SwitchBuf()')
|
|
|
|
|
screen:expect_unchanged()
|
|
|
|
|
end)
|
|
|
|
|
|
2023-11-12 19:47:12 -07:00
|
|
|
|
-- oldtest: Test_matchparen_pum_clear()
|
|
|
|
|
it('is cleared when completion popup is shown', function()
|
|
|
|
|
local screen = Screen.new(30, 9)
|
|
|
|
|
|
|
|
|
|
exec([[
|
|
|
|
|
source $VIMRUNTIME/plugin/matchparen.vim
|
|
|
|
|
set completeopt=menuone
|
|
|
|
|
call setline(1, ['aa', 'aaa', 'aaaa', '(a)'])
|
|
|
|
|
call cursor(4, 3)
|
|
|
|
|
]])
|
|
|
|
|
|
|
|
|
|
feed('i<C-X><C-N><C-N>')
|
2024-08-24 15:07:43 -07:00
|
|
|
|
screen:expect([[
|
2023-11-12 19:47:12 -07:00
|
|
|
|
aa |
|
|
|
|
|
aaa |
|
|
|
|
|
aaaa |
|
|
|
|
|
(aaa^) |
|
2024-03-27 02:35:50 -07:00
|
|
|
|
{4: aa }{1: }|
|
|
|
|
|
{12: aaa }{1: }|
|
|
|
|
|
{4: aaaa }{1: }|
|
|
|
|
|
{1:~ }|
|
|
|
|
|
{5:-- }{6:match 2 of 3} |
|
2024-08-24 15:07:43 -07:00
|
|
|
|
]])
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
-- oldtest: Test_matchparen_mbyte()
|
|
|
|
|
it("works with multibyte chars in 'matchpairs'", function()
|
|
|
|
|
local screen = Screen.new(30, 10)
|
2024-11-08 03:45:55 -07:00
|
|
|
|
screen:add_extra_attr_ids {
|
|
|
|
|
[100] = { background = Screen.colors.Cyan1 },
|
|
|
|
|
}
|
2024-08-24 15:07:43 -07:00
|
|
|
|
|
|
|
|
|
exec([[
|
|
|
|
|
source $VIMRUNTIME/plugin/matchparen.vim
|
|
|
|
|
call setline(1, ['aaaaaaaa(', 'bbbb)cc'])
|
|
|
|
|
set matchpairs+=(:)
|
|
|
|
|
]])
|
|
|
|
|
|
|
|
|
|
screen:expect([[
|
|
|
|
|
^aaaaaaaa( |
|
|
|
|
|
bbbb)cc |
|
2024-11-08 03:45:55 -07:00
|
|
|
|
{1:~ }|*7
|
2024-08-24 15:07:43 -07:00
|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
feed('$')
|
|
|
|
|
screen:expect([[
|
2024-11-08 03:45:55 -07:00
|
|
|
|
aaaaaaaa{100:^(} |
|
|
|
|
|
bbbb{100:)}cc |
|
|
|
|
|
{1:~ }|*7
|
2024-08-24 15:07:43 -07:00
|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
feed('j')
|
|
|
|
|
screen:expect([[
|
|
|
|
|
aaaaaaaa( |
|
|
|
|
|
bbbb)c^c |
|
2024-11-08 03:45:55 -07:00
|
|
|
|
{1:~ }|*7
|
2024-08-24 15:07:43 -07:00
|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
feed('2h')
|
|
|
|
|
screen:expect([[
|
2024-11-08 03:45:55 -07:00
|
|
|
|
aaaaaaaa{100:(} |
|
|
|
|
|
bbbb{100:^)}cc |
|
|
|
|
|
{1:~ }|*7
|
2024-08-24 15:07:43 -07:00
|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
feed('0')
|
|
|
|
|
screen:expect([[
|
|
|
|
|
aaaaaaaa( |
|
|
|
|
|
^bbbb)cc |
|
2024-11-08 03:45:55 -07:00
|
|
|
|
{1:~ }|*7
|
2024-08-24 15:07:43 -07:00
|
|
|
|
|
|
|
|
|
|
]])
|
|
|
|
|
feed('kA')
|
|
|
|
|
screen:expect([[
|
2024-11-08 03:45:55 -07:00
|
|
|
|
aaaaaaaa{100:(}^ |
|
|
|
|
|
bbbb{100:)}cc |
|
|
|
|
|
{1:~ }|*7
|
|
|
|
|
{5:-- INSERT --} |
|
2024-08-24 15:07:43 -07:00
|
|
|
|
]])
|
|
|
|
|
feed('<Down>')
|
|
|
|
|
screen:expect([[
|
|
|
|
|
aaaaaaaa( |
|
|
|
|
|
bbbb)cc^ |
|
2024-11-08 03:45:55 -07:00
|
|
|
|
{1:~ }|*7
|
|
|
|
|
{5:-- INSERT --} |
|
2024-08-24 15:07:43 -07:00
|
|
|
|
]])
|
|
|
|
|
feed('<C-W>')
|
|
|
|
|
screen:expect([[
|
2024-11-08 03:45:55 -07:00
|
|
|
|
aaaaaaaa{100:(} |
|
|
|
|
|
bbbb{100:)}^ |
|
|
|
|
|
{1:~ }|*7
|
|
|
|
|
{5:-- INSERT --} |
|
2024-08-24 15:07:43 -07:00
|
|
|
|
]])
|
2023-11-12 19:47:12 -07:00
|
|
|
|
end)
|
|
|
|
|
end)
|