aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ex_cmds')
-rw-r--r--test/functional/ex_cmds/bang_filter_spec.lua51
-rw-r--r--test/functional/ex_cmds/cd_spec.lua46
-rw-r--r--test/functional/ex_cmds/cmd_map_spec.lua772
-rw-r--r--test/functional/ex_cmds/dict_notifications_spec.lua2
-rw-r--r--test/functional/ex_cmds/drop_spec.lua32
-rw-r--r--test/functional/ex_cmds/map_spec.lua28
-rw-r--r--test/functional/ex_cmds/mksession_spec.lua3
-rw-r--r--test/functional/ex_cmds/mkview_spec.lua2
-rw-r--r--test/functional/ex_cmds/oldfiles_spec.lua1
-rw-r--r--test/functional/ex_cmds/sign_spec.lua4
-rw-r--r--test/functional/ex_cmds/write_spec.lua31
11 files changed, 870 insertions, 102 deletions
diff --git a/test/functional/ex_cmds/bang_filter_spec.lua b/test/functional/ex_cmds/bang_filter_spec.lua
deleted file mode 100644
index aaec983b73..0000000000
--- a/test/functional/ex_cmds/bang_filter_spec.lua
+++ /dev/null
@@ -1,51 +0,0 @@
--- Specs for bang/filter commands
-
-local helpers = require('test.functional.helpers')(after_each)
-local feed, command, clear = helpers.feed, helpers.command, helpers.clear
-local mkdir, write_file, rmdir = helpers.mkdir, helpers.write_file, helpers.rmdir
-
-if helpers.pending_win32(pending) then return end
-
-local Screen = require('test.functional.ui.screen')
-
-
-describe('issues', function()
- local screen
-
- before_each(function()
- clear()
- rmdir('bang_filter_spec')
- mkdir('bang_filter_spec')
- write_file('bang_filter_spec/f1', 'f1')
- write_file('bang_filter_spec/f2', 'f2')
- write_file('bang_filter_spec/f3', 'f3')
- screen = Screen.new()
- screen:attach()
- end)
-
- after_each(function()
- rmdir('bang_filter_spec')
- end)
-
- it('#3269 Last line of shell output is not truncated', function()
- command([[nnoremap <silent>\l :!ls bang_filter_spec<cr>]])
- feed([[\l]])
- screen:expect([[
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- ~ |
- :!ls bang_filter_spec |
- |
- f1 |
- f2 |
- f3 |
- Press ENTER or type command to continue^ |
- ]])
- end)
-
-end)
diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua
index 059cb26d5d..bc2b365b30 100644
--- a/test/functional/ex_cmds/cd_spec.lua
+++ b/test/functional/ex_cmds/cd_spec.lua
@@ -8,8 +8,7 @@ local call = helpers.call
local clear = helpers.clear
local command = helpers.command
local exc_exec = helpers.exc_exec
-
-if helpers.pending_win32(pending) then return end
+local pathsep = helpers.get_pathsep()
-- These directories will be created for testing
local directories = {
@@ -75,8 +74,8 @@ for _, cmd in ipairs {'cd', 'chdir'} do
eq(0, lwd(globalwin, tabnr))
-- Window with local dir reports as such
- eq(globalDir .. '/' .. directories.window, cwd(localwin))
- eq(globalDir .. '/' .. directories.window, cwd(localwin, tabnr))
+ eq(globalDir .. pathsep .. directories.window, cwd(localwin))
+ eq(globalDir .. pathsep .. directories.window, cwd(localwin, tabnr))
eq(1, lwd(localwin))
eq(1, lwd(localwin, tabnr))
@@ -86,7 +85,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do
eq(0, lwd(globalwin, tabnr))
-- From new tab page, local window reports as such
- eq(globalDir .. '/' .. directories.window, cwd(localwin, tabnr))
+ eq(globalDir .. pathsep .. directories.window, cwd(localwin, tabnr))
eq(1, lwd(localwin, tabnr))
end)
@@ -109,14 +108,14 @@ for _, cmd in ipairs {'cd', 'chdir'} do
eq(0, lwd(-1, globaltab))
-- new tab reports local
- eq(globalDir .. '/' .. directories.tab, cwd(-1, 0))
- eq(globalDir .. '/' .. directories.tab, cwd(-1, localtab))
+ eq(globalDir .. pathsep .. directories.tab, cwd(-1, 0))
+ eq(globalDir .. pathsep .. directories.tab, cwd(-1, localtab))
eq(1, lwd(-1, 0))
eq(1, lwd(-1, localtab))
command('tabnext')
-- From original tab page, local reports as such
- eq(globalDir .. '/' .. directories.tab, cwd(-1, localtab))
+ eq(globalDir .. pathsep .. directories.tab, cwd(-1, localtab))
eq(1, lwd(-1, localtab))
end)
end)
@@ -147,17 +146,17 @@ for _, cmd in ipairs {'cd', 'chdir'} do
-- Create a new tab and change directory
command('tabnew')
command('silent t' .. cmd .. ' ' .. directories.tab)
- eq(globalDir .. '/' .. directories.tab, tcwd())
+ eq(globalDir .. pathsep .. directories.tab, tcwd())
-- Create a new tab and verify it has inherited the directory
command('tabnew')
- eq(globalDir .. '/' .. directories.tab, tcwd())
+ eq(globalDir .. pathsep .. directories.tab, tcwd())
-- Change tab and change back, verify that directories are correct
command('tabnext')
eq(globalDir, tcwd())
command('tabprevious')
- eq(globalDir .. '/' .. directories.tab, tcwd())
+ eq(globalDir .. pathsep .. directories.tab, tcwd())
end)
end)
@@ -173,7 +172,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do
-- Change tab-local working directory and verify it is different
command('silent t' .. cmd .. ' ' .. directories.tab)
- eq(globalDir .. '/' .. directories.tab, cwd())
+ eq(globalDir .. pathsep .. directories.tab, cwd())
eq(cwd(), tcwd()) -- working directory maches tab directory
eq(1, tlwd())
eq(cwd(), wcwd()) -- still no window-directory
@@ -183,16 +182,16 @@ for _, cmd in ipairs {'cd', 'chdir'} do
command('new')
eq(1, tlwd()) -- Still tab-local working directory
eq(0, wlwd()) -- Still no window-local working directory
- eq(globalDir .. '/' .. directories.tab, cwd())
+ eq(globalDir .. pathsep .. directories.tab, cwd())
command('silent l' .. cmd .. ' ../' .. directories.window)
- eq(globalDir .. '/' .. directories.window, cwd())
- eq(globalDir .. '/' .. directories.tab, tcwd())
+ eq(globalDir .. pathsep .. directories.window, cwd())
+ eq(globalDir .. pathsep .. directories.tab, tcwd())
eq(1, wlwd())
-- Verify the first window still has the tab local directory
command('wincmd w')
- eq(globalDir .. '/' .. directories.tab, cwd())
- eq(globalDir .. '/' .. directories.tab, tcwd())
+ eq(globalDir .. pathsep .. directories.tab, cwd())
+ eq(globalDir .. pathsep .. directories.tab, tcwd())
eq(0, wlwd()) -- No window-local directory
-- Change back to initial tab and verify working directory has stayed
@@ -203,10 +202,10 @@ for _, cmd in ipairs {'cd', 'chdir'} do
-- Verify global changes don't affect local ones
command('silent ' .. cmd .. ' ' .. directories.global)
- eq(globalDir .. '/' .. directories.global, cwd())
+ eq(globalDir .. pathsep .. directories.global, cwd())
command('tabnext')
- eq(globalDir .. '/' .. directories.tab, cwd())
- eq(globalDir .. '/' .. directories.tab, tcwd())
+ eq(globalDir .. pathsep .. directories.tab, cwd())
+ eq(globalDir .. pathsep .. directories.tab, tcwd())
eq(0, wlwd()) -- Still no window-local directory in this window
-- Unless the global change happened in a tab with local directory
@@ -220,9 +219,9 @@ for _, cmd in ipairs {'cd', 'chdir'} do
-- But not in a window with its own local directory
command('tabnext | wincmd w')
- eq(globalDir .. '/' .. directories.window, cwd() )
+ eq(globalDir .. pathsep .. directories.window, cwd() )
eq(0 , tlwd())
- eq(globalDir .. '/' .. directories.window, wcwd())
+ eq(globalDir .. pathsep .. directories.window, wcwd())
end)
end)
end
@@ -280,6 +279,9 @@ describe("getcwd()", function ()
end)
it("returns empty string if working directory does not exist", function()
+ if helpers.iswin() then
+ return
+ end
command("cd "..directories.global)
command("call delete('../"..directories.global.."', 'd')")
eq("", helpers.eval("getcwd()"))
diff --git a/test/functional/ex_cmds/cmd_map_spec.lua b/test/functional/ex_cmds/cmd_map_spec.lua
new file mode 100644
index 0000000000..77d025dcc7
--- /dev/null
+++ b/test/functional/ex_cmds/cmd_map_spec.lua
@@ -0,0 +1,772 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear = helpers.clear
+local feed_command = helpers.feed_command
+local feed = helpers.feed
+local eq = helpers.eq
+local expect = helpers.expect
+local eval = helpers.eval
+local funcs = helpers.funcs
+local insert = helpers.insert
+local exc_exec = helpers.exc_exec
+local Screen = require('test.functional.ui.screen')
+
+describe('mappings with <Cmd>', function()
+ local screen
+ local function cmdmap(lhs, rhs)
+ feed_command('noremap '..lhs..' <Cmd>'..rhs..'<cr>')
+ feed_command('noremap! '..lhs..' <Cmd>'..rhs..'<cr>')
+ end
+
+ before_each(function()
+ clear()
+ screen = Screen.new(65, 8)
+ screen:set_default_attr_ids({
+ [1] = {bold = true, foreground = Screen.colors.Blue1},
+ [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
+ [3] = {bold = true, foreground = Screen.colors.SeaGreen4},
+ [4] = {bold = true},
+ [5] = {background = Screen.colors.LightGrey},
+ [6] = {foreground = Screen.colors.Blue1},
+ [7] = {bold = true, reverse = true},
+ })
+ screen:attach()
+
+ cmdmap('<F3>', 'let m = mode(1)')
+ cmdmap('<F4>', 'normal! ww')
+ cmdmap('<F5>', 'normal! "ay')
+ cmdmap('<F6>', 'throw "very error"')
+ feed_command([[
+ function! TextObj()
+ if mode() !=# "v"
+ normal! v
+ end
+ call cursor(1,3)
+ normal! o
+ call cursor(2,4)
+ endfunction]])
+ cmdmap('<F7>', 'call TextObj()')
+ insert([[
+ some short lines
+ of test text]])
+ feed('gg')
+ cmdmap('<F8>', 'startinsert')
+ cmdmap('<F9>', 'stopinsert')
+ feed_command("abbr foo <Cmd>let g:y = 17<cr>bar")
+ end)
+
+ it('can be displayed', function()
+ feed_command('map <F3>')
+ screen:expect([[
+ ^some short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {6:<F3>} {6:*} {6:<Cmd>}let m = mode(1){6:<CR>} |
+ ]])
+ end)
+
+ it('handles invalid mappings', function()
+ feed_command('let x = 0')
+ feed_command('noremap <F3> <Cmd><Cmd>let x = 1<cr>')
+ feed('<F3>')
+ screen:expect([[
+ ^some short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {2:E5521: <Cmd> mapping must end with <CR> before second <Cmd>} |
+ ]])
+
+ feed_command('noremap <F3> <Cmd><F3>let x = 2<cr>')
+ feed('<F3>')
+ screen:expect([[
+ ^some short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {2:E5522: <Cmd> mapping must not include <F3> key} |
+ ]])
+
+ feed_command('noremap <F3> <Cmd>let x = 3')
+ feed('<F3>')
+ screen:expect([[
+ ^some short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {2:E5520: <Cmd> mapping must end with <CR>} |
+ ]])
+ eq(0, eval('x'))
+ end)
+
+ it('works in various modes and sees correct `mode()` value', function()
+ -- normal mode
+ feed('<F3>')
+ eq('n', eval('m'))
+
+ -- visual mode
+ feed('v<F3>')
+ eq('v', eval('m'))
+ -- didn't leave visual mode
+ eq('v', eval('mode(1)'))
+ feed('<esc>')
+ eq('n', eval('mode(1)'))
+
+ -- visual mapping in select mode
+ feed('gh<F3>')
+ eq('v', eval('m'))
+ -- didn't leave select mode
+ eq('s', eval('mode(1)'))
+ feed('<esc>')
+ eq('n', eval('mode(1)'))
+
+ -- select mode mapping
+ feed_command('snoremap <F3> <Cmd>let m = mode(1)<cr>')
+ feed('gh<F3>')
+ eq('s', eval('m'))
+ -- didn't leave select mode
+ eq('s', eval('mode(1)'))
+ feed('<esc>')
+ eq('n', eval('mode(1)'))
+
+ -- operator-pending mode
+ feed("d<F3>")
+ eq('no', eval('m'))
+ -- did leave operator-pending mode
+ eq('n', eval('mode(1)'))
+
+ --insert mode
+ feed('i<F3>')
+ eq('i', eval('m'))
+ eq('i', eval('mode(1)'))
+
+ -- replace mode
+ feed("<Ins><F3>")
+ eq('R', eval('m'))
+ eq('R', eval('mode(1)'))
+ feed('<esc>')
+ eq('n', eval('mode(1)'))
+
+ -- virtual replace mode
+ feed("gR<F3>")
+ eq('Rv', eval('m'))
+ eq('Rv', eval('mode(1)'))
+ feed('<esc>')
+ eq('n', eval('mode(1)'))
+
+ -- langmap works, but is not distinguished in mode(1)
+ feed(":set iminsert=1<cr>i<F3>")
+ eq('i', eval('m'))
+ eq('i', eval('mode(1)'))
+ feed('<esc>')
+ eq('n', eval('mode(1)'))
+
+ feed(':<F3>')
+ eq('c', eval('m'))
+ eq('c', eval('mode(1)'))
+ feed('<esc>')
+ eq('n', eval('mode(1)'))
+
+ -- terminal mode
+ feed_command('tnoremap <F3> <Cmd>let m = mode(1)<cr>')
+ feed_command('split | terminal')
+ feed('i')
+ eq('t', eval('mode(1)'))
+ feed('<F3>')
+ eq('t', eval('m'))
+ eq('t', eval('mode(1)'))
+ end)
+
+ it('works in normal mode', function()
+ cmdmap('<F2>', 'let s = [mode(1), v:count, v:register]')
+
+ -- check v:count and v:register works
+ feed('<F2>')
+ eq({'n', 0, '"'}, eval('s'))
+ feed('7<F2>')
+ eq({'n', 7, '"'}, eval('s'))
+ feed('"e<F2>')
+ eq({'n', 0, 'e'}, eval('s'))
+ feed('5"k<F2>')
+ eq({'n', 5, 'k'}, eval('s'))
+ feed('"+2<F2>')
+ eq({'n', 2, '+'}, eval('s'))
+
+ -- text object enters visual mode
+ feed('<F7>')
+ screen:expect([[
+ so{5:me short lines} |
+ {5:of }^test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- VISUAL --} |
+ ]])
+ feed('<esc>')
+
+ -- startinsert
+ feed('<F8>')
+ eq('i', eval('mode(1)'))
+ feed('<esc>')
+
+ eq('n', eval('mode(1)'))
+ cmdmap(',a', 'call feedkeys("aalpha") \\| let g:a = getline(2)')
+ cmdmap(',b', 'call feedkeys("abeta", "x") \\| let g:b = getline(2)')
+
+ feed(',a<F3>')
+ screen:expect([[
+ some short lines |
+ of alpha^test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- INSERT --} |
+ ]])
+ -- feedkeys were not executed immediately
+ eq({'n', 'of test text'}, eval('[m,a]'))
+ eq('i', eval('mode(1)'))
+ feed('<esc>')
+
+ feed(',b<F3>')
+ screen:expect([[
+ some short lines |
+ of alphabet^atest text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+ -- feedkeys(..., 'x') was executed immediately, but insert mode gets aborted
+ eq({'n', 'of alphabetatest text'}, eval('[m,b]'))
+ eq('n', eval('mode(1)'))
+ end)
+
+ it('works in :normal command', function()
+ feed_command('noremap ,x <Cmd>call append(1, "xx")\\| call append(1, "aa")<cr>')
+ feed_command('noremap ,f <Cmd>nosuchcommand<cr>')
+ feed_command('noremap ,e <Cmd>throw "very error"\\| call append(1, "yy")<cr>')
+ feed_command('noremap ,m <Cmd>echoerr "The message."\\| call append(1, "zz")<cr>')
+ feed_command('noremap ,w <Cmd>for i in range(5)\\|if i==1\\|echoerr "Err"\\|endif\\|call append(1, i)\\|endfor<cr>')
+
+ feed(":normal ,x<cr>")
+ screen:expect([[
+ ^some short lines |
+ aa |
+ xx |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+
+ eq('Vim:E492: Not an editor command: nosuchcommand', exc_exec("normal ,f"))
+ eq('very error', exc_exec("normal ,e"))
+ eq('Vim(echoerr):The message.', exc_exec("normal ,m"))
+ feed('w')
+ screen:expect([[
+ some ^short lines |
+ aa |
+ xx |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+
+ feed_command(':%d')
+ eq('Vim(echoerr):Err', exc_exec("normal ,w"))
+ screen:expect([[
+ ^ |
+ 0 |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ --No lines in buffer-- |
+ ]])
+
+ feed_command(':%d')
+ feed_command(':normal ,w')
+ screen:expect([[
+ ^ |
+ 4 |
+ 3 |
+ 2 |
+ 1 |
+ 0 |
+ {1:~ }|
+ {2:Err} |
+ ]])
+ end)
+
+ it('works in visual mode', function()
+ -- can extend visual mode
+ feed('v<F4>')
+ screen:expect([[
+ {5:some short }^lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- VISUAL --} |
+ ]])
+ eq('v', funcs.mode(1))
+
+ -- can invoke operator, ending visual mode
+ feed('<F5>')
+ eq('n', funcs.mode(1))
+ eq({'some short l'}, funcs.getreg('a',1,1))
+
+ -- error doesn't interrupt visual mode
+ feed('ggvw<F6>')
+ screen:expect([[
+ {5:some }short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {7: }|
+ {2:Error detected while processing :} |
+ {2:E605: Exception not caught: very error} |
+ {3:Press ENTER or type command to continue}^ |
+ ]])
+ feed('<cr>')
+ eq('E605: Exception not caught: very error', eval('v:errmsg'))
+ -- still in visual mode, <cr> was consumed by the error prompt
+ screen:expect([[
+ {5:some }^short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- VISUAL --} |
+ ]])
+ eq('v', funcs.mode(1))
+ feed('<F7>')
+ screen:expect([[
+ so{5:me short lines} |
+ {5:of }^test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- VISUAL --} |
+ ]])
+ eq('v', funcs.mode(1))
+
+ -- startinsert gives "-- (insert) VISUAL --" mode
+ feed('<F8>')
+ screen:expect([[
+ so{5:me short lines} |
+ {5:of }^test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- (insert) VISUAL --} |
+ ]])
+ eq('v', eval('mode(1)'))
+ feed('<esc>')
+ eq('i', eval('mode(1)'))
+ end)
+
+ it('works in select mode', function()
+ feed_command('snoremap <F1> <cmd>throw "very error"<cr>')
+ feed_command('snoremap <F2> <cmd>normal! <c-g>"by<cr>')
+ -- can extend select mode
+ feed('gh<F4>')
+ screen:expect([[
+ {5:some short }^lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- SELECT --} |
+ ]])
+ eq('s', funcs.mode(1))
+
+ -- visual mapping in select mode restart selct mode after operator
+ feed('<F5>')
+ eq('s', funcs.mode(1))
+ eq({'some short l'}, funcs.getreg('a',1,1))
+
+ -- select mode mapping works, and does not restart select mode
+ feed('<F2>')
+ eq('n', funcs.mode(1))
+ eq({'some short l'}, funcs.getreg('b',1,1))
+
+ -- error doesn't interrupt temporary visual mode
+ feed('<esc>ggvw<c-g><F6>')
+ screen:expect([[
+ {5:some }short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {7: }|
+ {2:Error detected while processing :} |
+ {2:E605: Exception not caught: very error} |
+ {3:Press ENTER or type command to continue}^ |
+ ]])
+ feed('<cr>')
+ eq('E605: Exception not caught: very error', eval('v:errmsg'))
+ -- still in visual mode, <cr> was consumed by the error prompt
+ screen:expect([[
+ {5:some }^short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- VISUAL --} |
+ ]])
+ -- quirk: restoration of select mode is not performed
+ eq('v', funcs.mode(1))
+
+ -- error doesn't interrupt select mode
+ feed('<esc>ggvw<c-g><F1>')
+ screen:expect([[
+ {5:some }short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {7: }|
+ {2:Error detected while processing :} |
+ {2:E605: Exception not caught: very error} |
+ {3:Press ENTER or type command to continue}^ |
+ ]])
+ feed('<cr>')
+ eq('E605: Exception not caught: very error', eval('v:errmsg'))
+ -- still in select mode, <cr> was consumed by the error prompt
+ screen:expect([[
+ {5:some }^short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- SELECT --} |
+ ]])
+ -- quirk: restoration of select mode is not performed
+ eq('s', funcs.mode(1))
+
+ feed('<F7>')
+ screen:expect([[
+ so{5:me short lines} |
+ {5:of }^test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- SELECT --} |
+ ]])
+ eq('s', funcs.mode(1))
+
+ -- startinsert gives "-- SELECT (insert) --" mode
+ feed('<F8>')
+ screen:expect([[
+ so{5:me short lines} |
+ {5:of }^test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- (insert) SELECT --} |
+ ]])
+ eq('s', eval('mode(1)'))
+ feed('<esc>')
+ eq('i', eval('mode(1)'))
+ end)
+
+
+ it('works in operator-pending mode', function()
+ feed('d<F4>')
+ expect([[
+ lines
+ of test text]])
+ eq({'some short '}, funcs.getreg('"',1,1))
+ feed('.')
+ expect([[
+ test text]])
+ eq({'lines', 'of '}, funcs.getreg('"',1,1))
+ feed('uu')
+ expect([[
+ some short lines
+ of test text]])
+
+ -- error aborts operator-pending, operator not performed
+ feed('d<F6>')
+ screen:expect([[
+ some short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {7: }|
+ {2:Error detected while processing :} |
+ {2:E605: Exception not caught: very error} |
+ {3:Press ENTER or type command to continue}^ |
+ ]])
+ feed('<cr>')
+ eq('E605: Exception not caught: very error', eval('v:errmsg'))
+ expect([[
+ some short lines
+ of test text]])
+
+ feed('"bd<F7>')
+ expect([[
+ soest text]])
+ eq(funcs.getreg('b',1,1), {'me short lines', 'of t'})
+
+ -- startinsert aborts operator
+ feed('d<F8>')
+ eq('i', eval('mode(1)'))
+ expect([[
+ soest text]])
+ end)
+
+ it('works in insert mode', function()
+
+ -- works the same as <c-o>w<c-o>w
+ feed('iindeed <F4>little ')
+ screen:expect([[
+ indeed some short little ^lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- INSERT --} |
+ ]])
+
+ feed('<F6>')
+ screen:expect([[
+ indeed some short little lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {7: }|
+ {2:Error detected while processing :} |
+ {2:E605: Exception not caught: very error} |
+ {3:Press ENTER or type command to continue}^ |
+ ]])
+
+
+ feed('<cr>')
+ eq('E605: Exception not caught: very error', eval('v:errmsg'))
+ -- still in insert
+ screen:expect([[
+ indeed some short little ^lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- INSERT --} |
+ ]])
+ eq('i', eval('mode(1)'))
+
+ -- When entering visual mode from InsertEnter autocmd, an async event, or
+ -- a <cmd> mapping, vim ends up in undocumented "INSERT VISUAL" mode. If a
+ -- vim patch decides to disable this mode, this test is expected to fail.
+ feed('<F7>stuff ')
+ screen:expect([[
+ in{5:deed some short little lines} |
+ {5:of stuff }^test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- INSERT VISUAL --} |
+ ]])
+ expect([[
+ indeed some short little lines
+ of stuff test text]])
+
+ feed('<F5>')
+ eq(funcs.getreg('a',1,1), {'deed some short little lines', 'of stuff t'})
+
+ -- still in insert
+ screen:expect([[
+ in^deed some short little lines |
+ of stuff test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- INSERT --} |
+ ]])
+ eq('i', eval('mode(1)'))
+
+ -- also works as part of abbreviation
+ feed('<space>foo ')
+ screen:expect([[
+ in bar ^deed some short little lines |
+ of stuff test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- INSERT --} |
+ ]])
+ eq(17, eval('g:y'))
+
+ -- :startinsert does nothing
+ feed('<F8>')
+ eq('i', eval('mode(1)'))
+
+ -- :stopinsert works
+ feed('<F9>')
+ eq('n', eval('mode(1)'))
+ end)
+
+ it('works in cmdline mode', function()
+ cmdmap('<F2>', 'call setcmdpos(2)')
+ feed(':text<F3>')
+ eq('c', eval('m'))
+ -- didn't leave cmdline mode
+ eq('c', eval('mode(1)'))
+ feed('<cr>')
+ eq('n', eval('mode(1)'))
+ screen:expect([[
+ ^some short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {2:E492: Not an editor command: text} |
+ ]])
+
+ feed(':echo 2<F6>')
+ screen:expect([[
+ some short lines |
+ of test text |
+ {1:~ }|
+ {7: }|
+ :echo 2 |
+ {2:Error detected while processing :} |
+ {2:E605: Exception not caught: very error} |
+ :echo 2^ |
+ ]])
+ eq('E605: Exception not caught: very error', eval('v:errmsg'))
+ -- didn't leave cmdline mode
+ eq('c', eval('mode(1)'))
+ feed('+2<cr>')
+ screen:expect([[
+ some short lines |
+ of test text |
+ {7: }|
+ :echo 2 |
+ {2:Error detected while processing :} |
+ {2:E605: Exception not caught: very error} |
+ 4 |
+ {3:Press ENTER or type command to continue}^ |
+ ]])
+ -- however, message scrolling may cause extra CR prompt
+ -- This is consistent with output from async events.
+ feed('<cr>')
+ screen:expect([[
+ ^some short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+ eq('n', eval('mode(1)'))
+
+ feed(':let g:x = 3<F4>')
+ screen:expect([[
+ some short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ :let g:x = 3^ |
+ ]])
+ feed('+2<cr>')
+ -- cursor was moved in the background
+ screen:expect([[
+ some short ^lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ :let g:x = 3+2 |
+ ]])
+ eq(5, eval('g:x'))
+
+ feed(':let g:y = 7<F8>')
+ screen:expect([[
+ some short lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ :let g:y = 7^ |
+ ]])
+ eq('c', eval('mode(1)'))
+ feed('+2<cr>')
+ -- startinsert takes effect after leaving cmdline mode
+ screen:expect([[
+ some short ^lines |
+ of test text |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {4:-- INSERT --} |
+ ]])
+ eq('i', eval('mode(1)'))
+ eq(9, eval('g:y'))
+
+ end)
+
+end)
+
diff --git a/test/functional/ex_cmds/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua
index e3b4a1c504..3d550588e7 100644
--- a/test/functional/ex_cmds/dict_notifications_spec.lua
+++ b/test/functional/ex_cmds/dict_notifications_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, nvim, source = helpers.clear, helpers.nvim, helpers.source
-local eq, next_msg = helpers.eq, helpers.next_message
+local eq, next_msg = helpers.eq, helpers.next_msg
local exc_exec = helpers.exc_exec
local command = helpers.command
local eval = helpers.eval
diff --git a/test/functional/ex_cmds/drop_spec.lua b/test/functional/ex_cmds/drop_spec.lua
index 9105b84367..30dbd27d37 100644
--- a/test/functional/ex_cmds/drop_spec.lua
+++ b/test/functional/ex_cmds/drop_spec.lua
@@ -44,14 +44,14 @@ describe(":drop", function()
feed_command("edit tmp2")
feed_command("drop tmp1")
screen:expect([[
- {2:|}^ |
- {0:~ }{2:|}{0:~ }|
- {0:~ }{2:|}{0:~ }|
- {0:~ }{2:|}{0:~ }|
- {0:~ }{2:|}{0:~ }|
- {0:~ }{2:|}{0:~ }|
- {0:~ }{2:|}{0:~ }|
- {0:~ }{2:|}{0:~ }|
+ {2:│}^ |
+ {0:~ }{2:│}{0:~ }|
+ {0:~ }{2:│}{0:~ }|
+ {0:~ }{2:│}{0:~ }|
+ {0:~ }{2:│}{0:~ }|
+ {0:~ }{2:│}{0:~ }|
+ {0:~ }{2:│}{0:~ }|
+ {0:~ }{2:│}{0:~ }|
{2:tmp2 }{1:tmp1 }|
:drop tmp1 |
]])
@@ -64,14 +64,14 @@ describe(":drop", function()
feed("iABC<esc>")
feed_command("drop tmp3")
screen:expect([[
- ^ {2:|} |
- {0:~ }{2:|}{0:~ }|
- {0:~ }{2:|}{0:~ }|
- {0:~ }{2:|}{0:~ }|
- {1:tmp3 }{2:|}{0:~ }|
- ABC {2:|}{0:~ }|
- {0:~ }{2:|}{0:~ }|
- {0:~ }{2:|}{0:~ }|
+ ^ {2:│} |
+ {0:~ }{2:│}{0:~ }|
+ {0:~ }{2:│}{0:~ }|
+ {0:~ }{2:│}{0:~ }|
+ {1:tmp3 }{2:│}{0:~ }|
+ ABC {2:│}{0:~ }|
+ {0:~ }{2:│}{0:~ }|
+ {0:~ }{2:│}{0:~ }|
{2:tmp2 [+] tmp1 }|
"tmp3" [New File] |
]])
diff --git a/test/functional/ex_cmds/map_spec.lua b/test/functional/ex_cmds/map_spec.lua
new file mode 100644
index 0000000000..84d5bc2335
--- /dev/null
+++ b/test/functional/ex_cmds/map_spec.lua
@@ -0,0 +1,28 @@
+local helpers = require("test.functional.helpers")(after_each)
+
+local eq = helpers.eq
+local feed = helpers.feed
+local meths = helpers.meths
+local clear = helpers.clear
+local command = helpers.command
+local expect = helpers.expect
+
+describe(':*map', function()
+ before_each(clear)
+
+ it('are not affected by &isident', function()
+ meths.set_var('counter', 0)
+ command('nnoremap <C-x> :let counter+=1<CR>')
+ meths.set_option('isident', ('%u'):format(('>'):byte()))
+ command('nnoremap <C-y> :let counter+=1<CR>')
+ -- &isident used to disable keycode parsing here as well
+ feed('\24\25<C-x><C-y>')
+ eq(4, meths.get_var('counter'))
+ end)
+
+ it(':imap <M-">', function()
+ command('imap <M-"> foo')
+ feed('i-<M-">-')
+ expect('-foo-')
+ end)
+end)
diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua
index 5d658f10bb..a5b327095e 100644
--- a/test/functional/ex_cmds/mksession_spec.lua
+++ b/test/functional/ex_cmds/mksession_spec.lua
@@ -6,6 +6,7 @@ local command = helpers.command
local get_pathsep = helpers.get_pathsep
local eq = helpers.eq
local funcs = helpers.funcs
+local rmdir = helpers.rmdir
local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec'
@@ -20,7 +21,7 @@ describe(':mksession', function()
after_each(function()
os.remove(session_file)
- lfs.rmdir(tab_dir)
+ rmdir(tab_dir)
end)
it('restores tab-local working directories', function()
diff --git a/test/functional/ex_cmds/mkview_spec.lua b/test/functional/ex_cmds/mkview_spec.lua
index 97a49dbbd5..fef8065b2e 100644
--- a/test/functional/ex_cmds/mkview_spec.lua
+++ b/test/functional/ex_cmds/mkview_spec.lua
@@ -24,7 +24,7 @@ describe(':mkview', function()
after_each(function()
-- Remove any views created in the view directory
rmdir(view_dir)
- lfs.rmdir(local_dir)
+ rmdir(local_dir)
end)
it('viewoption curdir restores local current directory', function()
diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua
index 4002855c24..448326cdfb 100644
--- a/test/functional/ex_cmds/oldfiles_spec.lua
+++ b/test/functional/ex_cmds/oldfiles_spec.lua
@@ -29,6 +29,7 @@ describe(':oldfiles', function()
it('shows most recently used files', function()
local screen = Screen.new(100, 5)
screen:attach()
+ feed_command("set display-=msgsep")
feed_command('edit testfile1')
feed_command('edit testfile2')
feed_command('wshada')
diff --git a/test/functional/ex_cmds/sign_spec.lua b/test/functional/ex_cmds/sign_spec.lua
index b37e6e8563..df0f5db860 100644
--- a/test/functional/ex_cmds/sign_spec.lua
+++ b/test/functional/ex_cmds/sign_spec.lua
@@ -16,8 +16,8 @@ describe('sign', function()
nvim('command', 'sign place 34 line=3 name=Foo buffer='..buf2)
-- now unplace without specifying a buffer
nvim('command', 'sign unplace 34')
- eq("\n--- Signs ---\n", nvim('command_output', 'sign place buffer='..buf1))
- eq("\n--- Signs ---\n", nvim('command_output', 'sign place buffer='..buf2))
+ eq("--- Signs ---\n", nvim('command_output', 'sign place buffer='..buf1))
+ eq("--- Signs ---\n", nvim('command_output', 'sign place buffer='..buf2))
end)
end)
end)
diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua
index 863d439080..bcf83698bb 100644
--- a/test/functional/ex_cmds/write_spec.lua
+++ b/test/functional/ex_cmds/write_spec.lua
@@ -10,8 +10,6 @@ local feed_command = helpers.feed_command
local funcs = helpers.funcs
local meths = helpers.meths
-if helpers.pending_win32(pending) then return end
-
local fname = 'Xtest-functional-ex_cmds-write'
local fname_bak = fname .. '~'
local fname_broken = fname_bak .. 'broken'
@@ -36,7 +34,11 @@ describe(':write', function()
it('&backupcopy=auto preserves symlinks', function()
command('set backupcopy=auto')
write_file('test_bkc_file.txt', 'content0')
- command("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
+ if helpers.iswin() then
+ command("silent !mklink test_bkc_link.txt test_bkc_file.txt")
+ else
+ command("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
+ end
source([[
edit test_bkc_link.txt
call setline(1, ['content1'])
@@ -49,7 +51,11 @@ describe(':write', function()
it('&backupcopy=no replaces symlink with new file', function()
command('set backupcopy=no')
write_file('test_bkc_file.txt', 'content0')
- command("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
+ if helpers.iswin() then
+ command("silent !mklink test_bkc_link.txt test_bkc_file.txt")
+ else
+ command("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
+ end
source([[
edit test_bkc_link.txt
call setline(1, ['content1'])
@@ -82,8 +88,10 @@ describe(':write', function()
command('let $HOME=""')
eq(funcs.fnamemodify('.', ':p:h'), funcs.fnamemodify('.', ':p:h:~'))
-- Message from check_overwrite
- eq(('\nE17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'),
- redir_exec('write .'))
+ if not helpers.iswin() then
+ eq(('\nE17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'),
+ redir_exec('write .'))
+ end
meths.set_option('writeany', true)
-- Message from buf_write
eq(('\nE502: "." is a directory'),
@@ -100,9 +108,16 @@ describe(':write', function()
funcs.setfperm(fname, 'r--------')
eq('Vim(write):E505: "Xtest-functional-ex_cmds-write" is read-only (add ! to override)',
exc_exec('write'))
- os.remove(fname)
- os.remove(fname_bak)
+ if helpers.iswin() then
+ eq(0, os.execute('del /q/f ' .. fname))
+ eq(0, os.execute('rd /q/s ' .. fname_bak))
+ else
+ eq(true, os.remove(fname))
+ eq(true, os.remove(fname_bak))
+ end
write_file(fname_bak, 'TTYX')
+ -- FIXME: exc_exec('write!') outputs 0 in Windows
+ if helpers.iswin() then return end
lfs.link(fname_bak .. ('/xxxxx'):rep(20), fname, true)
eq('Vim(write):E166: Can\'t open linked file for writing',
exc_exec('write!'))