aboutsummaryrefslogtreecommitdiff
path: root/test/functional/editor/mode_normal_spec.lua
blob: d8d8b5e23040eb13141de5eef19c6f2a7074f0b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
-- Normal mode tests.

local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')

local describe, it, before_each = t.describe, t.it, t.before_each
local clear = n.clear
local feed = n.feed
local fn = n.fn
local command = n.command
local eq = t.eq
local api = n.api

describe('Normal mode', function()
  before_each(clear)

  it('setting &winhighlight or &winblend does not change curswant #27470', function()
    fn.setline(1, { 'long long lone line', 'short line' })
    feed('ggfi')
    local pos = fn.getcurpos()
    feed('j')
    command('setlocal winblend=10 winhighlight=Visual:Search')
    feed('k')
    eq(pos, fn.getcurpos())
  end)

  it('&showcmd does not crash with :startinsert #28419', function()
    local screen = Screen.new(60, 17)
    fn.jobstart({ n.nvim_prog, '--clean', '--cmd', 'startinsert' }, {
      term = true,
      env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
    })
    screen:expect({
      grid = [[
        ^                                                            |
        ~                                                           |*13
        [No Name]                                 0,1            All|
        -- INSERT --                                                |
                                                                    |
      ]],
      attr_ids = {},
    })
  end)

  it('replacing with ZWJ emoji sequences', function()
    local screen = Screen.new(30, 8)
    api.nvim_buf_set_lines(0, 0, -1, true, { 'abcdefg' })
    feed('05rπŸ§‘β€πŸŒΎ') -- ZWJ
    screen:expect([[
      πŸ§‘β€πŸŒΎπŸ§‘β€πŸŒΎπŸ§‘β€πŸŒΎπŸ§‘β€πŸŒΎ^πŸ§‘β€πŸŒΎfg                  |
      {1:~                             }|*6
                                    |
    ]])

    feed('2rπŸ³οΈβ€βš§οΈ') -- ZWJ and variant selectors
    screen:expect([[
      πŸ§‘β€πŸŒΎπŸ§‘β€πŸŒΎπŸ§‘β€πŸŒΎπŸ§‘β€πŸŒΎπŸ³οΈβ€βš§οΈ^πŸ³οΈβ€βš§οΈg                 |
      {1:~                             }|*6
                                    |
    ]])
  end)

  it('"gk" does not crash with signcolumn=yes in narrow window #31274', function()
    feed('o<Esc>')
    command('1vsplit | setlocal signcolumn=yes')
    feed('gk')
    n.assert_alive()
  end)

  it("'] after a forced blockwise exclusive motion", function()
    n.exec([=[
      function! Opfunc(type)
        let g:marks = [getpos("'[")[1:3], getpos("']")[1:3]]
      endfunction
      set operatorfunc=Opfunc
    ]=])
    fn.setline(1, { 'abcd' })
    feed('02|g@<C-v>l')
    eq({ { 1, 2, 0 }, { 1, 3, 0 } }, api.nvim_get_var('marks'))
    fn.setline(1, { 'ab cd' })
    feed('0y<C-v>w')
    eq({ 'ab c' }, fn.getreg('"', 1, 1))
    eq({ 0, 1, 4, 0 }, fn.getpos("']"))
    -- With 'selection' exclusive the block is only "b".
    command('set selection=exclusive')
    fn.setline(1, { 'abcd' })
    feed('02|y<C-v>l')
    eq({ 'b' }, fn.getreg('"', 1, 1))
    eq({ 0, 1, 2, 0 }, fn.getpos("']"))
  end)
end)