aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/api')
-rw-r--r--test/functional/api/extmark_spec.lua34
-rw-r--r--test/functional/api/vim_spec.lua73
2 files changed, 107 insertions, 0 deletions
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index ab913ba4a4..d2b555ee5b 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -1389,6 +1389,40 @@ describe('API/extmarks', function()
undo]],false)
eq(2, meths.eval('1+1')) -- did not crash
end)
+
+ it('works with left and right gravity', function()
+ -- right gravity should move with inserted text, while
+ -- left gravity should stay in place.
+ curbufmeths.set_extmark(ns, 0, 5, {right_gravity = false})
+ curbufmeths.set_extmark(ns, 0, 5, {right_gravity = true})
+ feed([[Aasdfasdf]])
+
+ eq({ {1, 0, 5}, {2, 0, 13} },
+ curbufmeths.get_extmarks(ns, 0, -1, {}))
+
+ -- but both move when text is inserted before
+ feed([[<esc>Iasdf<esc>]])
+ -- eq({}, curbufmeths.get_lines(0, -1, true))
+ eq({ {1, 0, 9}, {2, 0, 17} },
+ curbufmeths.get_extmarks(ns, 0, -1, {}))
+
+ -- clear text
+ curbufmeths.set_text(0, 0, 0, 17, {})
+
+ -- handles set_text correctly as well
+ eq({ {1, 0, 0}, {2, 0, 0} },
+ meths.buf_get_extmarks(0, ns, 0, -1, {}))
+ curbufmeths.set_text(0, 0, 0, 0, {'asdfasdf'})
+ eq({ {1, 0, 0}, {2, 0, 8} },
+ curbufmeths.get_extmarks(ns, 0, -1, {}))
+
+ feed('u')
+ -- handles pasting
+ meths.exec([[let @a='asdfasdf']], false)
+ feed([["ap]])
+ eq({ {1, 0, 0}, {2, 0, 8} },
+ meths.buf_get_extmarks(0, ns, 0, -1, {}))
+ end)
end)
describe('Extmarks buffer api with many marks', function()
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 30128e9c40..3ff3efb8c9 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -2002,4 +2002,77 @@ describe('API', function()
}, meths.get_option_info'showcmd')
end)
end)
+
+ describe('nvim_echo', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new(40, 8)
+ screen:attach()
+ screen:set_default_attr_ids({
+ [0] = {bold=true, foreground=Screen.colors.Blue},
+ [1] = {bold = true, foreground = Screen.colors.SeaGreen},
+ [2] = {bold = true, reverse = true},
+ [3] = {foreground = Screen.colors.Brown, bold = true}, -- Statement
+ [4] = {foreground = Screen.colors.SlateBlue}, -- Special
+ })
+ command('highlight Statement gui=bold guifg=Brown')
+ command('highlight Special guifg=SlateBlue')
+ end)
+
+ it('should clear cmdline message before echo', function()
+ feed(':call nvim_echo([["msg"]], v:false, {})<CR>')
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ msg |
+ ]]}
+ end)
+
+ it('can show highlighted line', function()
+ nvim_async("echo", {{"msg_a"}, {"msg_b", "Statement"}, {"msg_c", "Special"}}, true, {})
+ screen:expect{grid=[[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ msg_a{3:msg_b}{4:msg_c} |
+ ]]}
+ end)
+
+ it('can show highlighted multiline', function()
+ nvim_async("echo", {{"msg_a\nmsg_a", "Statement"}, {"msg_b", "Special"}}, true, {})
+ screen:expect{grid=[[
+ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {2: }|
+ {3:msg_a} |
+ {3:msg_a}{4:msg_b} |
+ {1:Press ENTER or type command to continue}^ |
+ ]]}
+ end)
+
+ it('can save message history', function()
+ nvim('command', 'set cmdheight=2') -- suppress Press ENTER
+ nvim("echo", {{"msg\nmsg"}, {"msg"}}, true, {})
+ eq("msg\nmsgmsg", meths.exec('messages', true))
+ end)
+
+ it('can disable saving message history', function()
+ nvim('command', 'set cmdheight=2') -- suppress Press ENTER
+ nvim_async("echo", {{"msg\nmsg"}, {"msg"}}, false, {})
+ eq("", meths.exec("messages", true))
+ end)
+ end)
end)