aboutsummaryrefslogtreecommitdiff
path: root/test/functional/options/pastetoggle_spec.lua
blob: a1f86f73ffb87c519ce2b63d272ec207b7dcea5e (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
local helpers = require('test.functional.helpers')(after_each)

local clear = helpers.clear
local feed = helpers.feed
local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
local sleep = helpers.sleep
local expect = helpers.expect

describe("'pastetoggle' option", function()
  before_each(function()
    clear()
    command('set nopaste')
  end)

  it("toggles 'paste'", function()
    command('set pastetoggle=a')
    eq(0, eval('&paste'))
    feed('a')
    -- Need another key so that the vgetorpeek() function returns.
    feed('j')
    eq(1, eval('&paste'))
  end)


  it('does not wait for timeout', function()
    command('set pastetoggle=abc')
    command('set ttimeoutlen=9999999')
    eq(0, eval('&paste'))
    -- n.b. need <esc> to return from vgetorpeek()
    feed('abc<esc>')
    eq(1, eval('&paste'))
    feed('ab')
    sleep(10)
    feed('c<esc>')
    expect('bc')
    eq(1, eval('&paste'))
  end)
end)