aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-02-03 12:36:17 +0100
committerGitHub <noreply@github.com>2017-02-03 12:36:17 +0100
commit8b804948df3751909e6e8de7adce66ac82f8f3f0 (patch)
tree3bb913376e6b0441ca391165626614d981371ff7 /test
parente8899178ec34e8432fc2e63f2970b0962e72c74c (diff)
parentf8b21b6d82a4bd50810c71b63632e5ba514feb76 (diff)
downloadrneovim-8b804948df3751909e6e8de7adce66ac82f8f3f0.tar.gz
rneovim-8b804948df3751909e6e8de7adce66ac82f8f3f0.tar.bz2
rneovim-8b804948df3751909e6e8de7adce66ac82f8f3f0.zip
Merge #5975 from jamessan/execute-with-attrs
execute: Correctly capture output with highlight attributes
Diffstat (limited to 'test')
-rw-r--r--test/functional/eval/execute_spec.lua55
1 files changed, 52 insertions, 3 deletions
diff --git a/test/functional/eval/execute_spec.lua b/test/functional/eval/execute_spec.lua
index cc9b61b842..91966ed3dd 100644
--- a/test/functional/eval/execute_spec.lua
+++ b/test/functional/eval/execute_spec.lua
@@ -8,6 +8,7 @@ local exc_exec = helpers.exc_exec
local funcs = helpers.funcs
local Screen = require('test.functional.ui.screen')
local command = helpers.command
+local feed = helpers.feed
describe('execute()', function()
before_each(clear)
@@ -21,7 +22,11 @@ describe('execute()', function()
eq("\nfoo\nbar", funcs.execute({'echo "foo"', 'echo "bar"'}))
end)
- it('supports nested redirection', function()
+ it('supports nested execute("execute(...)")', function()
+ eq('42', funcs.execute([[echon execute("echon execute('echon 42')")]]))
+ end)
+
+ it('supports nested :redir to a variable', function()
source([[
function! g:Foo()
let a = ''
@@ -33,14 +38,39 @@ describe('execute()', function()
function! g:Bar()
let a = ''
redir => a
+ silent echon "bar1"
call g:Foo()
+ silent echon "bar2"
redir END
+ silent echon "bar3"
return a
endfunction
]])
- eq('foo', funcs.execute('call g:Bar()'))
+ eq('top1bar1foobar2bar3', funcs.execute('echon "top1"|call g:Bar()'))
+ end)
- eq('42', funcs.execute([[echon execute("echon execute('echon 42')")]]))
+ it('supports nested :redir to a register', function()
+ source([[
+ let @a = ''
+ function! g:Foo()
+ redir @a>>
+ silent echon "foo"
+ redir END
+ return @a
+ endfunction
+ function! g:Bar()
+ redir @a>>
+ silent echon "bar1"
+ call g:Foo()
+ silent echon "bar2"
+ redir END
+ silent echon "bar3"
+ return @a
+ endfunction
+ ]])
+ eq('top1bar1foobar2bar3', funcs.execute('echon "top1"|call g:Bar()'))
+ -- :redir itself doesn't nest, so the redirection ends in g:Foo
+ eq('bar1foo', eval('@a'))
end)
it('captures a transformed string', function()
@@ -69,6 +99,25 @@ describe('execute()', function()
eq('Vim:E729: using Funcref as a String', ret)
end)
+ it('captures output with highlights', function()
+ eq('\nErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red',
+ eval('execute("hi ErrorMsg")'))
+ end)
+
+ it('does not corrupt the command display #5422', function()
+ local screen = Screen.new(70, 5)
+ screen:attach()
+ feed(':echo execute("hi ErrorMsg")<CR>')
+ screen:expect([[
+ ~ |
+ ~ |
+ :echo execute("hi ErrorMsg") |
+ ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red |
+ Press ENTER or type command to continue^ |
+ ]])
+ feed('<CR>')
+ end)
+
-- This matches Vim behavior.
it('does not capture shell-command output', function()
eq('\n:!echo "foo"\13\n', funcs.execute('!echo "foo"'))