aboutsummaryrefslogtreecommitdiff
path: root/test/functional/options
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-30 20:35:25 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-30 20:35:25 +0000
commit1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (patch)
treecd08258054db80bb9a11b1061bb091c70b76926a /test/functional/options
parenteaa89c11d0f8aefbb512de769c6c82f61a8baca3 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-aucmd_textputpost.tar.gz
rneovim-aucmd_textputpost.tar.bz2
rneovim-aucmd_textputpost.zip
Merge remote-tracking branch 'upstream/master' into aucmd_textputpostaucmd_textputpost
Diffstat (limited to 'test/functional/options')
-rw-r--r--test/functional/options/autochdir_spec.lua9
-rw-r--r--test/functional/options/cursorbind_spec.lua1
-rw-r--r--test/functional/options/defaults_spec.lua146
-rw-r--r--test/functional/options/keymap_spec.lua4
-rw-r--r--test/functional/options/mousescroll_spec.lua2
-rw-r--r--test/functional/options/num_options_spec.lua22
-rw-r--r--test/functional/options/pastetoggle_spec.lua90
7 files changed, 119 insertions, 155 deletions
diff --git a/test/functional/options/autochdir_spec.lua b/test/functional/options/autochdir_spec.lua
index 0b6fe9533c..c75a98f35b 100644
--- a/test/functional/options/autochdir_spec.lua
+++ b/test/functional/options/autochdir_spec.lua
@@ -1,9 +1,10 @@
-local lfs = require('lfs')
+local luv = require('luv')
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local funcs = helpers.funcs
local command = helpers.command
+local mkdir = helpers.mkdir
describe("'autochdir'", function()
it('given on the shell gets processed properly', function()
@@ -20,11 +21,11 @@ describe("'autochdir'", function()
end)
it('is not overwritten by getwinvar() call #17609',function()
- local curdir = string.gsub(lfs.currentdir(), '\\', '/')
+ local curdir = string.gsub(luv.cwd(), '\\', '/')
local dir_a = curdir..'/Xtest-functional-options-autochdir.dir_a'
local dir_b = curdir..'/Xtest-functional-options-autochdir.dir_b'
- lfs.mkdir(dir_a)
- lfs.mkdir(dir_b)
+ mkdir(dir_a)
+ mkdir(dir_b)
clear()
command('set shellslash')
command('set autochdir')
diff --git a/test/functional/options/cursorbind_spec.lua b/test/functional/options/cursorbind_spec.lua
index 1a03ed099a..498206936a 100644
--- a/test/functional/options/cursorbind_spec.lua
+++ b/test/functional/options/cursorbind_spec.lua
@@ -8,6 +8,7 @@ local feed = helpers.feed
before_each(clear)
describe("'cursorbind'", function()
+ -- oldtest: Test_cursorline_cursorbind_horizontal_scroll()
it("behaves consistently whether 'cursorline' is set or not vim-patch:8.2.4795", function()
local screen = Screen.new(60, 8)
screen:set_default_attr_ids({
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index 84ec43f4cb..7858b626de 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -8,6 +8,7 @@ local meths = helpers.meths
local command = helpers.command
local clear = helpers.clear
local exc_exec = helpers.exc_exec
+local exec_lua = helpers.exec_lua
local eval = helpers.eval
local eq = helpers.eq
local ok = helpers.ok
@@ -199,11 +200,23 @@ describe('startup defaults', function()
it("'shadafile' ('viminfofile')", function()
local env = {XDG_DATA_HOME='Xtest-userdata', XDG_STATE_HOME='Xtest-userstate', XDG_CONFIG_HOME='Xtest-userconfig'}
+ finally(function()
+ command('set shadafile=NONE') -- Avoid writing shada file on exit
+ rmdir('Xtest-userstate')
+ os.remove('Xtest-foo')
+ end)
+
clear{args={}, args_rm={'-i'}, env=env}
-- Default 'shadafile' is empty.
-- This means use the default location. :help shada-file-name
- eq('', meths.get_option('shadafile'))
- eq('', meths.get_option('viminfofile'))
+ eq('', meths.get_option_value('shadafile', {}))
+ eq('', meths.get_option_value('viminfofile', {}))
+ -- Handles viminfo/viminfofile as alias for shada/shadafile.
+ eq('\n shadafile=', eval('execute("set shadafile?")'))
+ eq('\n shadafile=', eval('execute("set viminfofile?")'))
+ eq("\n shada=!,'100,<50,s10,h", eval('execute("set shada?")'))
+ eq("\n shada=!,'100,<50,s10,h", eval('execute("set viminfo?")'))
+
-- Check that shada data (such as v:oldfiles) is saved/restored.
command('edit Xtest-foo')
command('write')
@@ -212,14 +225,6 @@ describe('startup defaults', function()
expect_exit(command, 'qall')
clear{args={}, args_rm={'-i'}, env=env}
eq({ f }, eval('v:oldfiles'))
- os.remove('Xtest-foo')
- rmdir('Xtest-userstate')
-
- -- Handles viminfo/viminfofile as alias for shada/shadafile.
- eq('\n shadafile=', eval('execute("set shadafile?")'))
- eq('\n shadafile=', eval('execute("set viminfofile?")'))
- eq("\n shada=!,'100,<50,s10,h", eval('execute("set shada?")'))
- eq("\n shada=!,'100,<50,s10,h", eval('execute("set viminfo?")'))
end)
it("'packpath'", function()
@@ -227,13 +232,13 @@ describe('startup defaults', function()
args_rm={'runtimepath'},
}
-- Defaults to &runtimepath.
- eq(meths.get_option('runtimepath'), meths.get_option('packpath'))
+ eq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {}))
-- Does not follow modifications to runtimepath.
meths.command('set runtimepath+=foo')
- neq(meths.get_option('runtimepath'), meths.get_option('packpath'))
+ neq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {}))
meths.command('set packpath+=foo')
- eq(meths.get_option('runtimepath'), meths.get_option('packpath'))
+ eq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {}))
end)
it('v:progpath is set to the absolute path', function()
@@ -318,10 +323,10 @@ describe('XDG defaults', function()
USER=nil,
}})
- eq('.', meths.get_option('backupdir'))
- eq('.', meths.get_option('viewdir'))
- eq('.', meths.get_option('directory'))
- eq('.', meths.get_option('undodir'))
+ eq('.', meths.get_option_value('backupdir', {}))
+ eq('.', meths.get_option_value('viewdir', {}))
+ eq('.', meths.get_option_value('directory', {}))
+ eq('.', meths.get_option_value('undodir', {}))
ok((funcs.tempname()):len() > 4)
end)
end)
@@ -383,7 +388,7 @@ describe('XDG defaults', function()
.. ',' .. root_path .. ('/b'):rep(2048) .. '/nvim/after'
.. ',' .. root_path .. ('/a'):rep(2048) .. '/nvim/after'
.. ',' .. root_path .. ('/x'):rep(4096) .. '/nvim/after'
- ):gsub('\\', '/')), (meths.get_option('runtimepath')):gsub('\\', '/'))
+ ):gsub('\\', '/')), (meths.get_option_value('runtimepath', {})):gsub('\\', '/'))
meths.command('set runtimepath&')
meths.command('set backupdir&')
meths.command('set directory&')
@@ -407,15 +412,15 @@ describe('XDG defaults', function()
.. ',' .. root_path .. ('/b'):rep(2048) .. '/nvim/after'
.. ',' .. root_path .. ('/a'):rep(2048) .. '/nvim/after'
.. ',' .. root_path .. ('/x'):rep(4096) .. '/nvim/after'
- ):gsub('\\', '/')), (meths.get_option('runtimepath')):gsub('\\', '/'))
+ ):gsub('\\', '/')), (meths.get_option_value('runtimepath', {})):gsub('\\', '/'))
eq('.,' .. root_path .. ('/X'):rep(4096).. '/' .. state_dir .. '/backup//',
- (meths.get_option('backupdir'):gsub('\\', '/')))
+ (meths.get_option_value('backupdir', {}):gsub('\\', '/')))
eq(root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/swap//',
- (meths.get_option('directory')):gsub('\\', '/'))
+ (meths.get_option_value('directory', {})):gsub('\\', '/'))
eq(root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/undo//',
- (meths.get_option('undodir')):gsub('\\', '/'))
+ (meths.get_option_value('undodir', {})):gsub('\\', '/'))
eq(root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/view//',
- (meths.get_option('viewdir')):gsub('\\', '/'))
+ (meths.get_option_value('viewdir', {})):gsub('\\', '/'))
end)
end)
@@ -431,7 +436,12 @@ describe('XDG defaults', function()
XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR',
XDG_STATE_HOME='$XDG_CONFIG_HOME',
XDG_DATA_DIRS='$XDG_CONFIG_DIRS',
- }})
+ }
+ })
+ end)
+
+ after_each(function()
+ command('set shadafile=NONE') -- Avoid writing shada file on exit
end)
it('are not expanded', function()
@@ -450,7 +460,7 @@ describe('XDG defaults', function()
.. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site/after'
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
- ):gsub('\\', '/')), (meths.get_option('runtimepath')):gsub('\\', '/'))
+ ):gsub('\\', '/')), (meths.get_option_value('runtimepath', {})):gsub('\\', '/'))
meths.command('set runtimepath&')
meths.command('set backupdir&')
meths.command('set directory&')
@@ -466,15 +476,15 @@ describe('XDG defaults', function()
.. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site/after'
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
- ):gsub('\\', '/')), (meths.get_option('runtimepath')):gsub('\\', '/'))
+ ):gsub('\\', '/')), (meths.get_option_value('runtimepath', {})):gsub('\\', '/'))
eq(('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'),
- meths.get_option('backupdir'):gsub('\\', '/'))
+ meths.get_option_value('backupdir', {}):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'),
- meths.get_option('directory'):gsub('\\', '/'))
+ meths.get_option_value('directory', {}):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'),
- meths.get_option('undodir'):gsub('\\', '/'))
+ meths.get_option_value('undodir', {}):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'),
- meths.get_option('viewdir'):gsub('\\', '/'))
+ meths.get_option_value('viewdir', {}):gsub('\\', '/'))
meths.command('set all&')
eq(('$XDG_DATA_HOME/nvim'
.. ',$XDG_DATA_DIRS/nvim'
@@ -486,15 +496,15 @@ describe('XDG defaults', function()
.. ',$XDG_CONFIG_HOME/' .. data_dir .. '/site/after'
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
- ):gsub('\\', '/'), (meths.get_option('runtimepath')):gsub('\\', '/'))
+ ):gsub('\\', '/'), (meths.get_option_value('runtimepath', {})):gsub('\\', '/'))
eq(('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'),
- meths.get_option('backupdir'):gsub('\\', '/'))
+ meths.get_option_value('backupdir', {}):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'),
- meths.get_option('directory'):gsub('\\', '/'))
+ meths.get_option_value('directory', {}):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'),
- meths.get_option('undodir'):gsub('\\', '/'))
+ meths.get_option_value('undodir', {}):gsub('\\', '/'))
eq(('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'),
- meths.get_option('viewdir'):gsub('\\', '/'))
+ meths.get_option_value('viewdir', {}):gsub('\\', '/'))
eq(nil, (funcs.tempname()):match('XDG_RUNTIME_DIR'))
end)
end)
@@ -529,7 +539,7 @@ describe('XDG defaults', function()
.. ',-\\,-\\,-' .. path_sep .. 'nvim' .. path_sep .. 'after'
.. ',\\,-\\,-\\,' .. path_sep .. 'nvim' .. path_sep .. 'after'
.. ',\\, \\, \\,' .. path_sep .. 'nvim' .. path_sep .. 'after'
- ), meths.get_option('runtimepath'))
+ ), meths.get_option_value('runtimepath', {}))
meths.command('set runtimepath&')
meths.command('set backupdir&')
meths.command('set directory&')
@@ -549,15 +559,15 @@ describe('XDG defaults', function()
.. ',-\\,-\\,-' .. path_sep ..'nvim' .. path_sep ..'after'
.. ',\\,-\\,-\\,' .. path_sep ..'nvim' .. path_sep ..'after'
.. ',\\, \\, \\,' .. path_sep ..'nvim' .. path_sep ..'after'
- ), meths.get_option('runtimepath'))
+ ), meths.get_option_value('runtimepath', {}))
eq('.,\\,=\\,=\\,' .. path_sep .. state_dir .. '' .. path_sep ..'backup' .. (path_sep):rep(2),
- meths.get_option('backupdir'))
+ meths.get_option_value('backupdir', {}))
eq('\\,=\\,=\\,' .. path_sep ..'' .. state_dir .. '' .. path_sep ..'swap' .. (path_sep):rep(2),
- meths.get_option('directory'))
+ meths.get_option_value('directory', {}))
eq('\\,=\\,=\\,' .. path_sep ..'' .. state_dir .. '' .. path_sep ..'undo' .. (path_sep):rep(2),
- meths.get_option('undodir'))
+ meths.get_option_value('undodir', {}))
eq('\\,=\\,=\\,' .. path_sep ..'' .. state_dir .. '' .. path_sep ..'view' .. (path_sep):rep(2),
- meths.get_option('viewdir'))
+ meths.get_option_value('viewdir', {}))
end)
end)
end)
@@ -566,8 +576,12 @@ end)
describe('stdpath()', function()
-- Windows appends 'nvim-data' instead of just 'nvim' to prevent collisions
-- due to XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_STATE_HOME being the same.
- local datadir = is_os('win') and 'nvim-data' or 'nvim'
- local statedir = is_os('win') and 'nvim-data' or 'nvim'
+ local function maybe_data(name)
+ return is_os('win') and name .. '-data' or name
+ end
+
+ local datadir = maybe_data('nvim')
+ local statedir = maybe_data('nvim')
local env_sep = is_os('win') and ';' or ':'
it('acceptance', function()
@@ -583,7 +597,45 @@ describe('stdpath()', function()
assert_alive() -- Check for crash. #8393
end)
- context('returns a String', function()
+ it('reacts to $NVIM_APPNAME', function()
+ local appname = 'NVIM_APPNAME_TEST' .. ('_'):rep(106)
+ clear({env={ NVIM_APPNAME=appname }})
+ eq(appname, funcs.fnamemodify(funcs.stdpath('config'), ':t'))
+ eq(appname, funcs.fnamemodify(funcs.stdpath('cache'), ':t'))
+ eq(maybe_data(appname), funcs.fnamemodify(funcs.stdpath('log'), ':t'))
+ eq(maybe_data(appname), funcs.fnamemodify(funcs.stdpath('data'), ':t'))
+ eq(maybe_data(appname), funcs.fnamemodify(funcs.stdpath('state'), ':t'))
+ -- config_dirs and data_dirs are empty on windows, so don't check them on
+ -- that platform
+ if not is_os('win') then
+ eq(appname, funcs.fnamemodify(funcs.stdpath('config_dirs')[1], ':t'))
+ eq(appname, funcs.fnamemodify(funcs.stdpath('data_dirs')[1], ':t'))
+ end
+ assert_alive() -- Check for crash. #8393
+
+ -- Check that Nvim rejects invalid APPNAMEs
+ -- Call jobstart() and jobwait() in the same RPC request to reduce flakiness.
+ local function test_appname(testAppname, expected_exitcode)
+ local lua_code = string.format([[
+ local child = vim.fn.jobstart({ vim.v.progpath, '--clean', '--headless', '+qall!' }, { env = { NVIM_APPNAME = %q } })
+ return vim.fn.jobwait({ child }, %d)[1]
+ ]], alter_slashes(testAppname), 3000)
+ eq(expected_exitcode, exec_lua(lua_code))
+ end
+ -- Invalid appnames:
+ test_appname('a/../b', 1)
+ test_appname('../a', 1)
+ test_appname('a/..', 1)
+ test_appname('..', 1)
+ test_appname('.', 1)
+ test_appname('/', 1)
+ test_appname(is_os('win') and 'C:/a/b' or '/a/b', 1)
+ -- Valid appnames:
+ test_appname('a/b', 0)
+ test_appname('a/b\\c', 0)
+ end)
+
+ describe('returns a String', function()
describe('with "config"' , function ()
it('knows XDG_CONFIG_HOME', function()
@@ -718,7 +770,7 @@ describe('stdpath()', function()
end)
end)
- context('returns a List', function()
+ describe('returns a List', function()
-- Some OS specific variables the system would have set.
local function base_env()
if is_os('win') then
@@ -870,8 +922,8 @@ describe('stdpath()', function()
end)
it('on non-strings', function()
- eq('Vim(call):E731: using Dictionary as a String', exc_exec('call stdpath({"eris": 23})'))
- eq('Vim(call):E730: using List as a String', exc_exec('call stdpath([23])'))
+ eq('Vim(call):E731: Using a Dictionary as a String', exc_exec('call stdpath({"eris": 23})'))
+ eq('Vim(call):E730: Using a List as a String', exc_exec('call stdpath([23])'))
end)
end)
end)
diff --git a/test/functional/options/keymap_spec.lua b/test/functional/options/keymap_spec.lua
index 4fdc6ef4be..c390e3d943 100644
--- a/test/functional/options/keymap_spec.lua
+++ b/test/functional/options/keymap_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear, feed, eq = helpers.clear, helpers.feed, helpers.eq
local expect, command, eval = helpers.expect, helpers.command, helpers.eval
local insert, call = helpers.insert, helpers.call
-local funcs, dedent = helpers.funcs, helpers.dedent
+local exec_capture, dedent = helpers.exec_capture, helpers.dedent
-- First test it's implemented using the :lmap and :lnoremap commands, then
-- check those mappings behave as expected.
@@ -30,7 +30,7 @@ describe("'keymap' / :lmap", function()
command('lmapclear <buffer>')
command('set keymap=dvorak')
command('set nomore')
- local bindings = funcs.nvim_exec('lmap', true)
+ local bindings = exec_capture('lmap')
eq(dedent([[
l " @_
diff --git a/test/functional/options/mousescroll_spec.lua b/test/functional/options/mousescroll_spec.lua
index 5bff45a836..38a9692792 100644
--- a/test/functional/options/mousescroll_spec.lua
+++ b/test/functional/options/mousescroll_spec.lua
@@ -20,7 +20,7 @@ end
describe("'mousescroll'", function()
local invalid_arg = 'Vim(set):E474: Invalid argument: mousescroll='
- local digit_expected = 'Vim(set):E548: digit expected: mousescroll='
+ local digit_expected = 'Vim(set):E5080: Digit expected: mousescroll='
local function should_fail(val, errorstr)
eq(errorstr..val, exc_exec('set mousescroll='..val))
diff --git a/test/functional/options/num_options_spec.lua b/test/functional/options/num_options_spec.lua
index f343e2da75..16a53c75e6 100644
--- a/test/functional/options/num_options_spec.lua
+++ b/test/functional/options/num_options_spec.lua
@@ -11,7 +11,7 @@ local function should_fail(opt, value, errmsg)
feed_command('setlocal ' .. opt .. '=' .. value)
eq(errmsg, eval("v:errmsg"):match("E%d*"))
feed_command('let v:errmsg = ""')
- local status, err = pcall(meths.set_option, opt, value)
+ local status, err = pcall(meths.set_option_value, opt, value, {})
eq(status, false)
eq(errmsg, err:match("E%d*"))
eq('', eval("v:errmsg"))
@@ -20,8 +20,8 @@ end
local function should_succeed(opt, value)
feed_command('setglobal ' .. opt .. '=' .. value)
feed_command('setlocal ' .. opt .. '=' .. value)
- meths.set_option(opt, value)
- eq(value, meths.get_option(opt))
+ meths.set_option_value(opt, value, {})
+ eq(value, meths.get_option_value(opt, {}))
eq('', eval("v:errmsg"))
end
@@ -29,12 +29,12 @@ describe(':setlocal', function()
before_each(clear)
it('setlocal sets only local value', function()
- eq(0, meths.get_option('iminsert'))
+ eq(0, meths.get_option_value('iminsert', {scope='global'}))
feed_command('setlocal iminsert=1')
- eq(0, meths.get_option('iminsert'))
- eq(-1, meths.get_option('imsearch'))
+ eq(0, meths.get_option_value('iminsert', {scope='global'}))
+ eq(-1, meths.get_option_value('imsearch', {scope='global'}))
feed_command('setlocal imsearch=1')
- eq(-1, meths.get_option('imsearch'))
+ eq(-1, meths.get_option_value('imsearch', {scope='global'}))
end)
end)
@@ -77,8 +77,8 @@ describe(':set validation', function()
-- If smaller than 1 this one is set to 'lines'-1
feed_command('setglobal window=-10')
- meths.set_option('window', -10)
- eq(23, meths.get_option('window'))
+ meths.set_option_value('window', -10, {})
+ eq(23, meths.get_option_value('window', {}))
eq('', eval("v:errmsg"))
-- 'scrolloff' and 'sidescrolloff' can have a -1 value when
@@ -112,8 +112,8 @@ describe(':set validation', function()
local function setto(value)
feed_command('setglobal maxcombine=' .. value)
feed_command('setlocal maxcombine=' .. value)
- meths.set_option('maxcombine', value)
- eq(6, meths.get_option('maxcombine'))
+ meths.set_option_value('maxcombine', value, {})
+ eq(6, meths.get_option_value('maxcombine', {}))
eq('', eval("v:errmsg"))
end
setto(0)
diff --git a/test/functional/options/pastetoggle_spec.lua b/test/functional/options/pastetoggle_spec.lua
deleted file mode 100644
index 40c14fa187..0000000000
--- a/test/functional/options/pastetoggle_spec.lua
+++ /dev/null
@@ -1,90 +0,0 @@
-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 expect = helpers.expect
-local eval = helpers.eval
-local insert = helpers.insert
-local meths = helpers.meths
-local sleep = helpers.sleep
-
-describe("'pastetoggle' option", function()
- before_each(clear)
- 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)
- describe("multiple key 'pastetoggle'", function()
- before_each(function()
- eq(0, eval('&paste'))
- command('set timeoutlen=1 ttimeoutlen=10000')
- end)
- it('is waited for when chars are typed', function()
- local pastetoggle = 'lllll'
- command('set pastetoggle=' .. pastetoggle)
- feed(pastetoggle:sub(0, 2))
- -- sleep() for long enough that vgetorpeek() is gotten into, but short
- -- enough that ttimeoutlen is not reached.
- sleep(200)
- feed(pastetoggle:sub(3, -1))
- -- Need another key so that the vgetorpeek() function returns.
- feed('j')
- eq(1, eval('&paste'))
- end)
-
- it('is not waited for when there are no typed chars after mapped chars', function()
- command('set pastetoggle=abc')
- command('imap d a')
- meths.feedkeys('id', 't', true)
- -- sleep() for long enough that vgetorpeek() is gotten into, but short
- -- enough that ttimeoutlen is not reached.
- sleep(200)
- feed('bc')
- -- Need another key so that the vgetorpeek() function returns.
- feed('j')
- -- 'ttimeoutlen' should NOT apply
- eq(0, eval('&paste'))
- end)
-
- it('is waited for when there are typed chars after mapped chars', function()
- command('set pastetoggle=abc')
- command('imap d a')
- meths.feedkeys('idb', 't', true)
- -- sleep() for long enough that vgetorpeek() is gotten into, but short
- -- enough that ttimeoutlen is not reached.
- sleep(200)
- feed('c')
- -- Need another key so that the vgetorpeek() function returns.
- feed('j')
- -- 'ttimeoutlen' should apply
- eq(1, eval('&paste'))
- end)
-
- it('is waited for when there are typed chars after noremapped chars', function()
- command('set pastetoggle=abc')
- command('inoremap d a')
- meths.feedkeys('idb', 't', true)
- -- sleep() for long enough that vgetorpeek() is gotten into, but short
- -- enough that ttimeoutlen is not reached.
- sleep(200)
- feed('c')
- -- Need another key so that the vgetorpeek() function returns.
- feed('j')
- -- 'ttimeoutlen' should apply
- eq(1, eval('&paste'))
- end)
- end)
- it('does not interfere with character-find', function()
- insert('foo,bar')
- feed('0')
- command('set pastetoggle=,sp')
- feed('dt,')
- expect(',bar')
- end)
-end)