aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/execute_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/eval/execute_spec.lua')
-rw-r--r--test/functional/eval/execute_spec.lua135
1 files changed, 133 insertions, 2 deletions
diff --git a/test/functional/eval/execute_spec.lua b/test/functional/eval/execute_spec.lua
index af37ab8d55..f52ac4e59b 100644
--- a/test/functional/eval/execute_spec.lua
+++ b/test/functional/eval/execute_spec.lua
@@ -114,7 +114,7 @@ describe('execute()', function()
{1:~ }|
{1:~ }|
{2: }|
- :echo execute("hi ErrorMsg") |
+ |
ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red |
{3:Press ENTER or type command to continue}^ |
]], {
@@ -125,9 +125,140 @@ describe('execute()', function()
feed('<CR>')
end)
+ it('places cursor correctly #6035', function()
+ local screen = Screen.new(40, 6)
+ screen:attach()
+ source([=[
+ " test 1: non-silenced output goes as usual
+ function! Test1()
+ echo 1234
+ let x = execute('echon "abcdef"', '')
+ echon 'ABCD'
+ endfunction
+
+ " test 2: silenced output does not affect ui
+ function! Test2()
+ echo 1234
+ let x = execute('echon "abcdef"', 'silent')
+ echon 'ABCD'
+ endfunction
+
+ " test 3: silenced! error does not affect ui
+ function! Test3()
+ echo 1234
+ let x = execute('echoerr "abcdef"', 'silent!')
+ echon 'ABCD'
+ endfunction
+
+ " test 4: silenced echoerr goes as usual
+ " bug here
+ function! Test4()
+ echo 1234
+ let x = execute('echoerr "abcdef"', 'silent')
+ echon 'ABCD'
+ endfunction
+
+ " test 5: silenced! echoerr does not affect ui
+ function! Test5()
+ echo 1234
+ let x = execute('echoerr "abcdef"', 'silent!')
+ echon 'ABCD'
+ endfunction
+
+ " test 6: silenced error goes as usual
+ function! Test6()
+ echo 1234
+ let x = execute('echo undefined', 'silent')
+ echon 'ABCD'
+ endfunction
+
+ " test 7: existing error does not mess the result
+ function! Test7()
+ " display from Test6() is still visible
+ " why does the "abcdef" goes into a newline
+ let x = execute('echon "abcdef"', '')
+ echon 'ABCD'
+ endfunction
+ ]=])
+
+ feed([[:call Test1()<cr>]])
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ABCD |
+ ]])
+
+ feed([[:call Test2()<cr>]])
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ 1234ABCD |
+ ]])
+
+ feed([[:call Test3()<cr>]])
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ 1234ABCD |
+ ]])
+
+ feed([[:call Test4()<cr>]])
+ -- unexpected: need to fix
+ -- echoerr does not set did_emsg
+ -- "ef" was overwritten since msg_col was recovered wrongly
+ screen:expect([[
+ 1234 |
+ Error detected while processing function|
+ Test4: |
+ line 2: |
+ abcdABCD |
+ Press ENTER or type command to continue^ |
+ ]])
+
+ feed([[<cr>]]) -- to clear screen
+ feed([[:call Test5()<cr>]])
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ 1234ABCD |
+ ]])
+
+ feed([[:call Test6()<cr>]])
+ screen:expect([[
+ |
+ Error detected while processing function|
+ Test6: |
+ line 2: |
+ E121ABCD |
+ Press ENTER or type command to continue^ |
+ ]])
+
+ feed([[:call Test7()<cr>]])
+ screen:expect([[
+ Error detected while processing function|
+ Test6: |
+ line 2: |
+ E121ABCD |
+ ABCD |
+ Press ENTER or type command to continue^ |
+ ]])
+ end)
+
-- This deviates from vim behavior, but is consistent
-- with how nvim currently displays the output.
- it('does capture shell-command output', function()
+ it('captures shell-command output', function()
local win_lf = iswin() and '\13' or ''
eq('\n:!echo foo\r\n\nfoo'..win_lf..'\n', funcs.execute('!echo foo'))
end)