2017-04-01 12:50:29 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
|
|
|
|
local clear = helpers.clear
|
|
|
|
local feed = helpers.feed
|
2017-04-08 13:48:22 -07:00
|
|
|
local command = helpers.command
|
2017-04-01 12:50:29 -07:00
|
|
|
local eq = helpers.eq
|
|
|
|
local eval = helpers.eval
|
|
|
|
local sleep = helpers.sleep
|
2017-05-31 04:20:06 -07:00
|
|
|
local expect = helpers.expect
|
2017-04-01 12:50:29 -07:00
|
|
|
|
|
|
|
describe("'pastetoggle' option", function()
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
2017-04-08 13:48:22 -07:00
|
|
|
command('set nopaste')
|
2017-04-01 12:50:29 -07:00
|
|
|
end)
|
2017-05-31 04:20:06 -07:00
|
|
|
|
2017-04-01 12:50:29 -07:00
|
|
|
it("toggles 'paste'", function()
|
2017-05-31 04:20:06 -07:00
|
|
|
command('set pastetoggle=a')
|
|
|
|
eq(0, eval('&paste'))
|
2017-04-01 12:50:29 -07:00
|
|
|
feed('a')
|
|
|
|
-- Need another key so that the vgetorpeek() function returns.
|
|
|
|
feed('j')
|
2017-05-31 04:20:06 -07:00
|
|
|
eq(1, eval('&paste'))
|
2017-04-01 12:50:29 -07:00
|
|
|
end)
|
2017-05-31 04:20:06 -07:00
|
|
|
|
|
|
|
|
|
|
|
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'))
|
2017-04-01 12:50:29 -07:00
|
|
|
end)
|
|
|
|
end)
|