diff options
-rw-r--r-- | src/nvim/api/vim.c | 10 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 38 |
2 files changed, 45 insertions, 3 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index b5e53beabe..75592ae3a7 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -104,10 +104,14 @@ String nvim_exec(String src, Boolean output, Error *err) } try_start(); - msg_silent++; + if (output) { + msg_silent++; + } do_source_str(src.data, "nvim_exec()"); - capture_ga = save_capture_ga; - msg_silent = save_msg_silent; + if (output) { + capture_ga = save_capture_ga; + msg_silent = save_msg_silent; + } try_end(err); if (ERROR_SET(err)) { diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 3db44f3f11..6926022ee3 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -193,6 +193,44 @@ describe('API', function() eq('', nvim('exec', 'echo', true)) eq('foo 42', nvim('exec', 'echo "foo" 42', true)) end) + + it('displays messages when output=false', function() + local screen = Screen.new(40, 8) + screen:attach() + screen:set_default_attr_ids({ + [0] = {bold=true, foreground=Screen.colors.Blue}, + }) + meths.exec("echo 'hello'", false) + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + hello | + ]]} + end) + + it('does\'t display messages when output=true', function() + local screen = Screen.new(40, 8) + screen:attach() + screen:set_default_attr_ids({ + [0] = {bold=true, foreground=Screen.colors.Blue}, + }) + meths.exec("echo 'hello'", true) + screen:expect{grid=[[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]} + end) end) describe('nvim_command', function() |