aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-09-15 00:35:33 +0100
committerGitHub <noreply@github.com>2021-09-14 16:35:33 -0700
commit6188926e00081ae4b1a33d5fd12692a6749a2144 (patch)
treef8d12f0e0f4c1e22ca0df6824d276228fb7f7516 /test/functional/ex_cmds
parent9edd17509fca597b847656adc8fc20fc1cc44ce5 (diff)
downloadrneovim-6188926e00081ae4b1a33d5fd12692a6749a2144.tar.gz
rneovim-6188926e00081ae4b1a33d5fd12692a6749a2144.tar.bz2
rneovim-6188926e00081ae4b1a33d5fd12692a6749a2144.zip
fix(:source, nvim_exec): handle Vimscript line continuations #14809
Problem: Anonymous :source (no args) and nvim_exec() don't support Vimscript line continuations. Solution: Factor out the concat logic into concat_continued_line() and a CONCAT_CONTINUED_LINES macro for simple concatenations where lines are fetched individually. Closes #14807
Diffstat (limited to 'test/functional/ex_cmds')
-rw-r--r--test/functional/ex_cmds/source_spec.lua52
1 files changed, 42 insertions, 10 deletions
diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua
index 37c97f519a..3cef412bb6 100644
--- a/test/functional/ex_cmds/source_spec.lua
+++ b/test/functional/ex_cmds/source_spec.lua
@@ -8,6 +8,8 @@ local feed = helpers.feed
local feed_command = helpers.feed_command
local write_file = helpers.write_file
local exec = helpers.exec
+local exc_exec = helpers.exc_exec
+local exec_lua = helpers.exec_lua
local eval = helpers.eval
local exec_capture = helpers.exec_capture
local neq = helpers.neq
@@ -18,16 +20,30 @@ describe(':source', function()
end)
it('current buffer', function()
- insert('let a = 2')
+ insert([[
+ let a = 2
+ let b = #{
+ \ k: "v"
+ "\ (o_o)
+ \ }]])
+
command('source')
eq('2', meths.exec('echo a', true))
+ eq("{'k': 'v'}", meths.exec('echo b', true))
+
+ exec('set cpoptions+=C')
+ eq('Vim(let):E15: Invalid expression: #{', exc_exec('source'))
end)
it('selection in current buffer', function()
- insert(
- 'let a = 2\n'..
- 'let a = 3\n'..
- 'let a = 4\n')
+ insert([[
+ let a = 2
+ let a = 3
+ let a = 4
+ let b = #{
+ "\ (>_<)
+ \ K: "V"
+ \ }]])
-- Source the 2nd line only
feed('ggjV')
@@ -38,13 +54,17 @@ describe(':source', function()
feed('ggjVG')
feed_command(':source')
eq('4', meths.exec('echo a', true))
+ eq("{'K': 'V'}", meths.exec('echo b', true))
+
+ exec('set cpoptions+=C')
+ eq('Vim(let):E15: Invalid expression: #{', exc_exec("'<,'>source"))
end)
it('multiline heredoc command', function()
- insert(
- 'lua << EOF\n'..
- 'y = 4\n'..
- 'EOF\n')
+ insert([[
+ lua << EOF
+ y = 4
+ EOF]])
command('source')
eq('4', meths.exec('echo luaeval("y")', true))
@@ -67,13 +87,21 @@ describe(':source', function()
vim.g.b = 5
vim.g.b = 6
vim.g.b = 7
+ a = [=[
+ "\ a
+ \ b]=]
]])
command('edit '..test_file)
+
feed('ggjV')
feed_command(':source')
-
eq(6, eval('g:b'))
+
+ feed('GVkk')
+ feed_command(':source')
+ eq(' "\\ a\n \\ b', exec_lua('return _G.a'))
+
os.remove(test_file)
end)
@@ -84,12 +112,16 @@ describe(':source', function()
vim.g.c = 10
vim.g.c = 11
vim.g.c = 12
+ a = [=[
+ \ 1
+ "\ 2]=]
]])
command('edit '..test_file)
feed_command(':source')
eq(12, eval('g:c'))
+ eq(' \\ 1\n "\\ 2', exec_lua('return _G.a'))
os.remove(test_file)
end)