From 73a2922413b4fd119fc0ec1cca06ba0982ad576a Mon Sep 17 00:00:00 2001 From: Sha Liu Date: Thu, 6 Dec 2018 22:27:25 +0800 Subject: UI: Fix wrong msg_col after execute() closes #6035 closes #9250 --- test/functional/eval/execute_spec.lua | 134 +++++++++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/functional/eval/execute_spec.lua b/test/functional/eval/execute_spec.lua index af37ab8d55..6f82b0d99c 100644 --- a/test/functional/eval/execute_spec.lua +++ b/test/functional/eval/execute_spec.lua @@ -125,9 +125,141 @@ describe('execute()', function() feed('') end) + it('places cursor correctly #6035', function() + local screen = Screen.new(40, 5) + screen:attach() + source([=[ + " test 1 + function! Test1a() + echo 12345678 + let x = execute('echo 1234567890', '') + echon '1234' + endfunction + + function! Test1b() + echo 12345678 + echo 1234567890 + echon '1234' + endfunction + + " test 2 + function! Test2a() + echo 12345678 + let x = execute('echo 1234567890', 'silent') + echon '1234' + endfunction + + function! Test2b() + echo 12345678 + silent echo 1234567890 + echon '1234' + endfunction + + " test 3 + function! Test3a() + echo 12345678 + let x = execute('echoerr 1234567890', 'silent!') + echon '1234' + endfunction + + function! Test3b() + echo 12345678 + silent! echoerr 1234567890 + echon '1234' + endfunction + + " test 4 + function! Test4a() + echo 12345678 + let x = execute('echoerr 1234567890', 'silent') + echon '1234' + endfunction + + function! Test4b() + echo 12345678 + silent echoerr 1234567890 + echon '1234' + endfunction + ]=]) + + feed([[:call Test1a()]]) + screen:expect([[ + | + | + 12345678 | + 12345678901234 | + Press ENTER or type command to continue^ | + ]]) + + feed([[:call Test1b()]]) + screen:expect([[ + 12345678 | + 12345678901234 | + 12345678 | + 12345678901234 | + Press ENTER or type command to continue^ | + ]]) + + feed([[:call Test2a()]]) + screen:expect([[ + 12345678901234 | + 12345678 | + 12345678901234 | + 123456781234 | + Press ENTER or type command to continue^ | + ]]) + + feed([[:call Test2b()]]) + screen:expect([[ + 12345678 | + 12345678901234 | + 123456781234 | + 123456781234 | + Press ENTER or type command to continue^ | + ]]) + + feed([[:call Test3a()]]) + screen:expect([[ + 12345678901234 | + 123456781234 | + 123456781234 | + 123456781234 | + Press ENTER or type command to continue^ | + ]]) + + feed([[:call Test3b()]]) + screen:expect([[ + 123456781234 | + 123456781234 | + 123456781234 | + 123456781234 | + Press ENTER or type command to continue^ | + ]]) + + feed([[:call Test4a()]]) + screen:expect([[ + Error detected while processing function| + Test4a: | + line 2: | + 123456781234 | + Press ENTER or type command to continue^ | + ]]) + + feed([[:call Test4b()]]) + screen:expect([[ + Error detected while processing function| + Test4b: | + line 2: | + 12345678901234 | + 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) -- cgit From 5a4e7af77d0f819d61604b9440cc2f6376a3186b Mon Sep 17 00:00:00 2001 From: Sha Liu Date: Sat, 8 Dec 2018 17:14:43 +0800 Subject: update functional test for "places cursor correctly #6035" --- test/functional/eval/execute_spec.lua | 169 +++++++++++++++++----------------- 1 file changed, 84 insertions(+), 85 deletions(-) (limited to 'test') diff --git a/test/functional/eval/execute_spec.lua b/test/functional/eval/execute_spec.lua index 6f82b0d99c..45664e1060 100644 --- a/test/functional/eval/execute_spec.lua +++ b/test/functional/eval/execute_spec.lua @@ -126,135 +126,134 @@ describe('execute()', function() end) it('places cursor correctly #6035', function() - local screen = Screen.new(40, 5) + local screen = Screen.new(40, 6) screen:attach() source([=[ - " test 1 - function! Test1a() - echo 12345678 - let x = execute('echo 1234567890', '') - echon '1234' + " test 1: non-silenced output goes as usual + function! Test1() + echo 1234 + let x = execute('echon "abcdef"', '') + echon 'ABCD' endfunction - function! Test1b() - echo 12345678 - echo 1234567890 - echon '1234' + " test 2: silenced output does not affect ui + function! Test2() + echo 1234 + let x = execute('echon "abcdef"', 'silent') + echon 'ABCD' endfunction - " test 2 - function! Test2a() - echo 12345678 - let x = execute('echo 1234567890', 'silent') - echon '1234' + " test 3: silenced! error does not affect ui + function! Test3() + echo 1234 + let x = execute('echoerr "abcdef"', 'silent!') + echon 'ABCD' endfunction - function! Test2b() - echo 12345678 - silent echo 1234567890 - echon '1234' + " test 4: silenced echoerr goes as usual + " bug here + function! Test4() + echo 1234 + let x = execute('echoerr "abcdef"', 'silent') + echon 'ABCD' endfunction - " test 3 - function! Test3a() - echo 12345678 - let x = execute('echoerr 1234567890', 'silent!') - echon '1234' + " test 5: silenced! echoerr does not affect ui + function! Test5() + echo 1234 + let x = execute('echoerr "abcdef"', 'silent!') + echon 'ABCD' endfunction - function! Test3b() - echo 12345678 - silent! echoerr 1234567890 - echon '1234' + " test 6: silenced error goes as usual + function! Test6() + echo 1234 + let x = execute('echo undefined', 'silent') + echon 'ABCD' endfunction - " test 4 - function! Test4a() - echo 12345678 - let x = execute('echoerr 1234567890', 'silent') - echon '1234' - endfunction - - function! Test4b() - echo 12345678 - silent echoerr 1234567890 - echon '1234' + " 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 Test1a()]]) + feed([[:call Test1()]]) screen:expect([[ - | - | - 12345678 | - 12345678901234 | - Press ENTER or type command to continue^ | - ]]) - - feed([[:call Test1b()]]) - screen:expect([[ - 12345678 | - 12345678901234 | - 12345678 | - 12345678901234 | - Press ENTER or type command to continue^ | + ^ | + ~ | + ~ | + ~ | + ~ | + 1234abcdefABCD | ]]) - feed([[:call Test2a()]]) + feed([[:call Test2()]]) screen:expect([[ - 12345678901234 | - 12345678 | - 12345678901234 | - 123456781234 | - Press ENTER or type command to continue^ | + ^ | + ~ | + ~ | + ~ | + ~ | + 1234ABCD | ]]) - feed([[:call Test2b()]]) + feed([[:call Test3()]]) screen:expect([[ - 12345678 | - 12345678901234 | - 123456781234 | - 123456781234 | - Press ENTER or type command to continue^ | + ^ | + ~ | + ~ | + ~ | + ~ | + 1234ABCD | ]]) - feed([[:call Test3a()]]) + feed([[:call Test4()]]) + -- unexpected: need to fix + -- echoerr does not set did_emsg + -- "ef" was overwritten since msg_col was recovered wrongly screen:expect([[ - 12345678901234 | - 123456781234 | - 123456781234 | - 123456781234 | + 1234 | + Error detected while processing function| + Test4: | + line 2: | + abcdABCD | Press ENTER or type command to continue^ | ]]) - feed([[:call Test3b()]]) + feed([[]]) -- to clear screen + feed([[:call Test5()]]) screen:expect([[ - 123456781234 | - 123456781234 | - 123456781234 | - 123456781234 | - Press ENTER or type command to continue^ | + ^ | + ~ | + ~ | + ~ | + ~ | + 1234ABCD | ]]) - feed([[:call Test4a()]]) + feed([[:call Test6()]]) screen:expect([[ + 1234 | Error detected while processing function| - Test4a: | + Test6: | line 2: | - 123456781234 | + E121: Undefined variable: undefinedABCD | Press ENTER or type command to continue^ | ]]) - feed([[:call Test4b()]]) + feed([[:call Test7()]]) screen:expect([[ Error detected while processing function| - Test4b: | + Test6: | line 2: | - 12345678901234 | + E121: Undefined variable: undefinedABCD | + abcdefABCD | Press ENTER or type command to continue^ | ]]) - - end) -- This deviates from vim behavior, but is consistent -- cgit From f0078c26c2949d9cd2020e0c95dc33eb26a60688 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 11 Dec 2018 21:29:10 -0500 Subject: functionaltests: fix new execute() tests --- test/functional/eval/execute_spec.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/functional/eval/execute_spec.lua b/test/functional/eval/execute_spec.lua index 45664e1060..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}^ | ]], { @@ -188,7 +188,7 @@ describe('execute()', function() ~ | ~ | ~ | - 1234abcdefABCD | + ABCD | ]]) feed([[:call Test2()]]) @@ -237,11 +237,11 @@ describe('execute()', function() feed([[:call Test6()]]) screen:expect([[ - 1234 | + | Error detected while processing function| Test6: | line 2: | - E121: Undefined variable: undefinedABCD | + E121ABCD | Press ENTER or type command to continue^ | ]]) @@ -250,8 +250,8 @@ describe('execute()', function() Error detected while processing function| Test6: | line 2: | - E121: Undefined variable: undefinedABCD | - abcdefABCD | + E121ABCD | + ABCD | Press ENTER or type command to continue^ | ]]) end) -- cgit