aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/autocmd_spec.lua
blob: 1071776b681a077661b52de0734e102ca0ef2fb8 (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
93
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')

local clear = n.clear
local write_file = t.write_file
local command = n.command
local feed = n.feed
local api = n.api
local eq = t.eq

before_each(clear)

-- oldtest: Test_autocmd_invalidates_undo_on_textchanged()
it('no E440 in quickfix window when autocommand invalidates undo', function()
  write_file(
    'XTest_autocmd_invalidates_undo_on_textchanged',
    [[
    set hidden
    " create quickfix list (at least 2 lines to move line)
    vimgrep /u/j %

    " enter quickfix window
    cwindow

    " set modifiable
    setlocal modifiable

    " set autocmd to clear quickfix list

    autocmd! TextChanged <buffer> call setqflist([])
    " move line
    move+1
    ]]
  )
  finally(function()
    os.remove('XTest_autocmd_invalidates_undo_on_textchanged')
  end)
  command('edit XTest_autocmd_invalidates_undo_on_textchanged')
  command('so %')
  feed('G')
  eq('', api.nvim_get_vvar('errmsg'))
end)

-- oldtest: Test_WinScrolled_Resized_eiw()
it('WinScrolled and WinResized events can be ignored in a window', function()
  local screen = Screen.new()
  n.exec([[
    call setline(1, ['foo']->repeat(32))
    set eventignorewin=WinScrolled,WinResized
    split
    let [g:afile,g:resized,g:scrolled] = ['none',0,0]
    au WinScrolled * let [g:afile,g:scrolled] = [expand('<afile>'),g:scrolled+1]
    au WinResized * let [g:afile,g:resized] = [expand('<afile>'),g:resized+1]
  ]])
  feed('<C-W>-')
  screen:expect([[
    ^foo                                                  |
    foo                                                  |*4
    {3:[No Name] [+]                                        }|
    foo                                                  |*6
    {2:[No Name] [+]                                        }|
                                                         |
  ]])
  feed(':echo g:afile g:resized g:scrolled<CR>')
  screen:expect({ any = 'none 0 0.*' })
  feed('G')
  screen:expect([[
    foo                                                  |*4
    ^foo                                                  |
    {3:[No Name] [+]                                        }|
    foo                                                  |*6
    {2:[No Name] [+]                                        }|
    none 0 0                                             |
  ]])
  feed('gg')
  screen:expect([[
    ^foo                                                  |
    foo                                                  |*4
    {3:[No Name] [+]                                        }|
    foo                                                  |*6
    {2:[No Name] [+]                                        }|
    none 0 0                                             |
  ]])
  feed(':echo g:afile g:resized g:scrolled')
  screen:expect({ any = ':echo g:afile g:resized g:scrolled.*' })
  feed('<CR>')
  screen:expect({ any = 'none 0 0.*' })
  feed(':set eventignorewin=<CR><C-W>w<C-W>+')
  screen:expect({ any = ':set eventignorewin=.*' })
  feed(':echo win_getid() g:afile g:resized g:scrolled<CR>')
  screen:expect({ any = '1000 1001 1 1.*' })
end)