aboutsummaryrefslogtreecommitdiff
path: root/test/functional/autocmd/modechanged_spec.lua
blob: be5a291ac9bbc9d418f6717a7ca2c819fb780ff4 (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
local helpers = require('test.functional.helpers')(after_each)
local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq
local feed, command = helpers.feed, helpers.command

describe('ModeChanged', function()
  before_each(function()
    clear()
    command('let g:count = 0')
    command('au ModeChanged * let g:event = copy(v:event)')
    command('au ModeChanged * let g:count += 1')
  end)

  it('picks up terminal mode changes', function()
    command("term")
    feed('i')
    eq({
      old_mode = 'nt',
      new_mode = 't'
    }, eval('g:event'))
    feed('<c-\\><c-n>')
    eq({
      old_mode = 't',
      new_mode = 'nt'
    }, eval('g:event'))
    eq(3, eval('g:count'))
    command("bd!")

    -- v:event is cleared after the autocommand is done
    eq({}, eval('v:event'))
  end)
end)