robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

robinmerge: 1dc9728daa1d8a2702

master
1.8 KiB62 linesraw
1local t = require('test.testutil')
2local n = require('test.functional.testnvim')()
3local Screen = require('test.functional.ui.screen')
4
5local describe, it, before_each = t.describe, t.it, t.before_each
6local clear = n.clear
7local command = n.command
8local api = n.api
9local feed = n.feed
10local eq = t.eq
11
12describe('matchparen', function()
13  local screen --- @type test.functional.ui.screen
14
15  before_each(function()
16    clear { args = { '-u', 'NORC' } }
17    screen = Screen.new(20, 5)
18    screen:set_default_attr_ids({
19      [0] = { bold = true, foreground = 255 },
20      [1] = { bold = true },
21    })
22  end)
23
24  it('uses correct column after i_<Up>. Vim patch 7.4.1296', function()
25    command('set noautoindent nosmartindent nocindent laststatus=0')
26    eq(1, api.nvim_get_var('loaded_matchparen'))
27    feed('ivoid f_test()<cr>')
28    feed('{<cr>')
29    feed('}')
30
31    -- critical part: up + cr should result in an empty line in between the
32    -- brackets... if the bug is there, the empty line will be before the '{'
33    feed('<up>')
34    feed('<cr>')
35
36    screen:expect([[
37      void f_test()       |
38      {                   |
39      ^                    |
40      }                   |
41      {1:-- INSERT --}        |
42    ]])
43  end)
44
45  it('skips treesitter strings in another window', function()
46    api.nvim_buf_set_lines(0, 0, -1, false, { 'print(")")' })
47    n.exec_lua(function()
48      vim.treesitter.start(0, 'lua')
49    end)
50    api.nvim_win_set_cursor(0, { 1, 5 })
51    local win = api.nvim_get_current_win()
52    command('new')
53    eq(
54      { { 1, 6, 1 }, { 1, 10, 1 } },
55      n.exec_lua(function(target_win)
56        require('nvim.matchparen').highlight_matching_pair(target_win)
57        local match = vim.fn.getmatches(target_win)[1]
58        return { match.pos1, match.pos2 }
59      end, win)
60    )
61  end)
62end)