aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/editor/macro_spec.lua47
-rw-r--r--test/functional/editor/mode_insert_spec.lua24
-rw-r--r--test/functional/ui/diff_spec.lua127
-rw-r--r--test/functional/ui/highlight_spec.lua22
-rw-r--r--test/unit/buffer_spec.lua42
5 files changed, 238 insertions, 24 deletions
diff --git a/test/functional/editor/macro_spec.lua b/test/functional/editor/macro_spec.lua
index c0c9256af2..d4cf6b28fd 100644
--- a/test/functional/editor/macro_spec.lua
+++ b/test/functional/editor/macro_spec.lua
@@ -6,11 +6,14 @@ local feed = helpers.feed
local clear = helpers.clear
local expect = helpers.expect
local command = helpers.command
+local funcs = helpers.funcs
+local meths = helpers.meths
local insert = helpers.insert
local curbufmeths = helpers.curbufmeths
+before_each(clear)
+
describe('macros', function()
- before_each(clear)
it('can be recorded and replayed', function()
feed('qiahello<esc>q')
expect('hello')
@@ -47,9 +50,47 @@ hello]]
end)
end)
-describe('reg_recorded()', function()
- before_each(clear)
+describe('immediately after a macro has finished executing,', function()
+ before_each(function()
+ command([[let @a = 'gg0']])
+ end)
+
+ describe('reg_executing() from RPC returns an empty string', function()
+ it('if the macro does not end with a <Nop> mapping', function()
+ feed('@a')
+ eq('', funcs.reg_executing())
+ end)
+
+ it('if the macro ends with a <Nop> mapping', function()
+ command('nnoremap 0 <Nop>')
+ feed('@a')
+ eq('', funcs.reg_executing())
+ end)
+ end)
+ describe('characters from a mapping are not treated as a part of the macro #18015', function()
+ before_each(function()
+ command('nnoremap s qa')
+ end)
+
+ it('if the macro does not end with a <Nop> mapping', function()
+ feed('@asq') -- "q" from "s" mapping should start recording a macro instead of being no-op
+ eq({mode = 'n', blocking = false}, meths.get_mode())
+ expect('')
+ eq('', eval('@a'))
+ end)
+
+ it('if the macro ends with a <Nop> mapping', function()
+ command('nnoremap 0 <Nop>')
+ feed('@asq') -- "q" from "s" mapping should start recording a macro instead of being no-op
+ eq({mode = 'n', blocking = false}, meths.get_mode())
+ expect('')
+ eq('', eval('@a'))
+ end)
+ end)
+end)
+
+describe('reg_recorded()', function()
it('returns the correct value', function()
feed [[qqyyq]]
eq('q', eval('reg_recorded()'))
diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua
index 528e228121..c38acbe96a 100644
--- a/test/functional/editor/mode_insert_spec.lua
+++ b/test/functional/editor/mode_insert_spec.lua
@@ -6,6 +6,8 @@ local expect = helpers.expect
local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
+local meths = helpers.meths
+local poke_eventloop = helpers.poke_eventloop
describe('insert-mode', function()
before_each(function()
@@ -128,4 +130,26 @@ describe('insert-mode', function()
expect('<M-1><D-2><M-7><D-8>')
end)
end)
+
+ describe([[With 'insertmode', Insert mode is not re-entered immediately after <C-L>]], function()
+ before_each(function()
+ command('set insertmode')
+ poke_eventloop()
+ eq({mode = 'i', blocking = false}, meths.get_mode())
+ end)
+
+ it('after calling :edit from <Cmd> mapping', function()
+ command('inoremap <C-B> <Cmd>edit Xfoo<CR>')
+ feed('<C-B><C-L>')
+ poke_eventloop()
+ eq({mode = 'n', blocking = false}, meths.get_mode())
+ end)
+
+ it('after calling :edit from RPC #16823', function()
+ command('edit Xfoo')
+ feed('<C-L>')
+ poke_eventloop()
+ eq({mode = 'n', blocking = false}, meths.get_mode())
+ end)
+ end)
end)
diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua
index 3a25d7e813..6f67dea2be 100644
--- a/test/functional/ui/diff_spec.lua
+++ b/test/functional/ui/diff_spec.lua
@@ -1226,3 +1226,130 @@ it('Align the filler lines when changing text in diff mode', function()
|
]]}
end)
+
+it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', function()
+ clear()
+ local screen = Screen.new(40, 20)
+ screen:set_default_attr_ids({
+ [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray};
+ [2] = {reverse = true};
+ [3] = {background = Screen.colors.LightBlue};
+ [4] = {background = Screen.colors.LightMagenta};
+ [5] = {background = Screen.colors.Red, bold = true};
+ [6] = {foreground = Screen.colors.Blue, bold = true};
+ [7] = {background = Screen.colors.Red, foreground = Screen.colors.Blue, bold = true};
+ [8] = {reverse = true, bold = true};
+ })
+ screen:attach()
+ exec([[
+ call setline(1, ['a', 'b', "c\n", 'd', 'e', 'f', 'g'])
+ vnew
+ call setline(1, ['A', 'b', 'c', 'd', 'E', 'f', 'g'])
+ windo diffthis
+ wincmd p
+ norm! gg0
+ redraw!
+ ]])
+
+ -- Test using internal diff
+ screen:expect([[
+ {1: }{5:^A}{4: }{2:│}{1: }{5:a}{4: }|
+ {1: }b {2:│}{1: }b |
+ {1: }{4:c }{2:│}{1: }{4:c}{7:^@}{4: }|
+ {1: }d {2:│}{1: }d |
+ {1: }{5:E}{4: }{2:│}{1: }{5:e}{4: }|
+ {1: }f {2:│}{1: }f |
+ {1: }g {2:│}{1: }g |
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {8:[No Name] [+] }{2:[No Name] [+] }|
+ |
+ ]])
+
+ -- Test using internal diff and case folding
+ command('set diffopt+=icase')
+ feed('<C-L>')
+ screen:expect([[
+ {1: }^A {2:│}{1: }a |
+ {1: }b {2:│}{1: }b |
+ {1: }{4:c }{2:│}{1: }{4:c}{7:^@}{4: }|
+ {1: }d {2:│}{1: }d |
+ {1: }E {2:│}{1: }e |
+ {1: }f {2:│}{1: }f |
+ {1: }g {2:│}{1: }g |
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {8:[No Name] [+] }{2:[No Name] [+] }|
+ |
+ ]])
+
+ -- Test using external diff
+ command('set diffopt=filler')
+ feed('<C-L>')
+ screen:expect([[
+ {1: }{5:^A}{4: }{2:│}{1: }{5:a}{4: }|
+ {1: }b {2:│}{1: }b |
+ {1: }{4:c }{2:│}{1: }{4:c}{7:^@}{4: }|
+ {1: }d {2:│}{1: }d |
+ {1: }{5:E}{4: }{2:│}{1: }{5:e}{4: }|
+ {1: }f {2:│}{1: }f |
+ {1: }g {2:│}{1: }g |
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {8:[No Name] [+] }{2:[No Name] [+] }|
+ |
+ ]])
+
+ -- Test using external diff and case folding
+ command('set diffopt+=filler,icase')
+ feed('<C-L>')
+ screen:expect([[
+ {1: }^A {2:│}{1: }a |
+ {1: }b {2:│}{1: }b |
+ {1: }{4:c }{2:│}{1: }{4:c}{7:^@}{4: }|
+ {1: }d {2:│}{1: }d |
+ {1: }E {2:│}{1: }e |
+ {1: }f {2:│}{1: }f |
+ {1: }g {2:│}{1: }g |
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {6:~ }{2:│}{6:~ }|
+ {8:[No Name] [+] }{2:[No Name] [+] }|
+ |
+ ]])
+end)
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 4b63b09a5b..8afc69a649 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -1345,6 +1345,28 @@ describe('CursorColumn highlight', function()
{2:~ }|
{3:-- INSERT --} |
]])
+ feed('<C-O>')
+ screen:expect([[
+ 1234567{1:8}9 |
+ a ^ b |
+ {2:~ }|
+ {2:~ }|
+ {2:~ }|
+ {2:~ }|
+ {2:~ }|
+ {3:-- (insert) --} |
+ ]])
+ feed('i')
+ screen:expect([[
+ 1{1:2}3456789 |
+ a^ b |
+ {2:~ }|
+ {2:~ }|
+ {2:~ }|
+ {2:~ }|
+ {2:~ }|
+ {3:-- INSERT --} |
+ ]])
end)
it('is updated if cursor is moved from timer', function()
diff --git a/test/unit/buffer_spec.lua b/test/unit/buffer_spec.lua
index 34c88248e6..833b21b00b 100644
--- a/test/unit/buffer_spec.lua
+++ b/test/unit/buffer_spec.lua
@@ -17,8 +17,8 @@ describe('buffer functions', function()
return buffer.buflist_new(c_file, c_file, 1, flags)
end
- local close_buffer = function(win, buf, action, abort_if_last)
- return buffer.close_buffer(win, buf, action, abort_if_last)
+ local close_buffer = function(win, buf, action, abort_if_last, ignore_abort)
+ return buffer.close_buffer(win, buf, action, abort_if_last, ignore_abort)
end
local path1 = 'test_file_path'
@@ -53,7 +53,7 @@ describe('buffer functions', function()
itp('should view a closed and hidden buffer as valid', function()
local buf = buflist_new(path1, buffer.BLN_LISTED)
- close_buffer(NULL, buf, 0, 0)
+ close_buffer(NULL, buf, 0, 0, 0)
eq(true, buffer.buf_valid(buf))
end)
@@ -61,7 +61,7 @@ describe('buffer functions', function()
itp('should view a closed and unloaded buffer as valid', function()
local buf = buflist_new(path1, buffer.BLN_LISTED)
- close_buffer(NULL, buf, buffer.DOBUF_UNLOAD, 0)
+ close_buffer(NULL, buf, buffer.DOBUF_UNLOAD, 0, 0)
eq(true, buffer.buf_valid(buf))
end)
@@ -69,7 +69,7 @@ describe('buffer functions', function()
itp('should view a closed and wiped buffer as invalid', function()
local buf = buflist_new(path1, buffer.BLN_LISTED)
- close_buffer(NULL, buf, buffer.DOBUF_WIPE, 0)
+ close_buffer(NULL, buf, buffer.DOBUF_WIPE, 0, 0)
eq(false, buffer.buf_valid(buf))
end)
@@ -90,7 +90,7 @@ describe('buffer functions', function()
eq(buf.handle, buflist_findpat(path1, ONLY_LISTED))
- close_buffer(NULL, buf, buffer.DOBUF_WIPE, 0)
+ close_buffer(NULL, buf, buffer.DOBUF_WIPE, 0, 0)
end)
itp('should prefer to match the start of a file path', function()
@@ -102,9 +102,9 @@ describe('buffer functions', function()
eq(buf2.handle, buflist_findpat("file", ONLY_LISTED))
eq(buf3.handle, buflist_findpat("path", ONLY_LISTED))
- close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0)
- close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0)
- close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0)
+ close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0, 0)
+ close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0, 0)
+ close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0, 0)
end)
itp('should prefer to match the end of a file over the middle', function()
@@ -118,7 +118,7 @@ describe('buffer functions', function()
--}
--{ When: We close buf2
- close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0)
+ close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0, 0)
-- And: Open buf1, which has 'file' in the middle of its name
local buf1 = buflist_new(path1, buffer.BLN_LISTED)
@@ -127,8 +127,8 @@ describe('buffer functions', function()
eq(buf3.handle, buflist_findpat("file", ONLY_LISTED))
--}
- close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0)
- close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0)
+ close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0, 0)
+ close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0, 0)
end)
itp('should match a unique fragment of a file path', function()
@@ -138,9 +138,9 @@ describe('buffer functions', function()
eq(buf3.handle, buflist_findpat("_test_", ONLY_LISTED))
- close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0)
- close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0)
- close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0)
+ close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0, 0)
+ close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0, 0)
+ close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0, 0)
end)
itp('should include / ignore unlisted buffers based on the flag.', function()
@@ -152,7 +152,7 @@ describe('buffer functions', function()
--}
--{ When: We unlist the buffer
- close_buffer(NULL, buf3, buffer.DOBUF_DEL, 0)
+ close_buffer(NULL, buf3, buffer.DOBUF_DEL, 0, 0)
-- Then: It should not find the buffer when searching only listed buffers
eq(-1, buflist_findpat("_test_", ONLY_LISTED))
@@ -162,7 +162,7 @@ describe('buffer functions', function()
--}
--{ When: We wipe the buffer
- close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0)
+ close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0, 0)
-- Then: It should not find the buffer at all
eq(-1, buflist_findpat("_test_", ONLY_LISTED))
@@ -180,7 +180,7 @@ describe('buffer functions', function()
--}
--{ When: The first buffer is unlisted
- close_buffer(NULL, buf1, buffer.DOBUF_DEL, 0)
+ close_buffer(NULL, buf1, buffer.DOBUF_DEL, 0, 0)
-- Then: The second buffer is preferred because
-- unlisted buffers are not allowed
@@ -194,7 +194,7 @@ describe('buffer functions', function()
--}
--{ When: We unlist the second buffer
- close_buffer(NULL, buf2, buffer.DOBUF_DEL, 0)
+ close_buffer(NULL, buf2, buffer.DOBUF_DEL, 0, 0)
-- Then: The first buffer is preferred again
-- because buf1 matches better which takes precedence
@@ -205,8 +205,8 @@ describe('buffer functions', function()
eq(-1, buflist_findpat("test", ONLY_LISTED))
--}
- close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0)
- close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0)
+ close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0, 0)
+ close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0, 0)
end)
end)