aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/api/ui_events.in.h4
-rw-r--r--src/nvim/eval.c11
-rw-r--r--test/functional/ui/cmdline_spec.lua39
3 files changed, 52 insertions, 2 deletions
diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h
index 17eefbe1d6..5602dc6df3 100644
--- a/src/nvim/api/ui_events.in.h
+++ b/src/nvim/api/ui_events.in.h
@@ -75,5 +75,9 @@ void cmdline_char(String c, Integer shift, Integer level)
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
void cmdline_hide(Integer level)
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+void cmdline_function_show(void)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
+void cmdline_function_hide(void)
+ FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
#endif // NVIM_API_UI_EVENTS_IN_H
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 3c9614dfcd..d5ff01e922 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -19816,6 +19816,10 @@ void ex_function(exarg_T *eap)
goto errret_2;
}
+ if (ui_is_external(kUICmdline)) {
+ ui_call_cmdline_function_show();
+ }
+
// find extra arguments "range", "dict", "abort" and "closure"
for (;; ) {
p = skipwhite(p);
@@ -19868,7 +19872,9 @@ void ex_function(exarg_T *eap)
if (!eap->skip && did_emsg)
goto erret;
- msg_putchar('\n'); /* don't overwrite the function name */
+ if (!ui_is_external(kUICmdline)) {
+ msg_putchar('\n'); /* don't overwrite the function name */
+ }
cmdline_row = msg_row;
}
@@ -20194,6 +20200,9 @@ ret_free:
xfree(name);
did_emsg |= saved_did_emsg;
need_wait_return |= saved_wait_return;
+ if (ui_is_external(kUICmdline)) {
+ ui_call_cmdline_function_hide();
+ }
}
/// Get a function name, translating "<SID>" and "<SNR>".
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua
index 479d40e959..9e2857bc95 100644
--- a/test/functional/ui/cmdline_spec.lua
+++ b/test/functional/ui/cmdline_spec.lua
@@ -7,7 +7,7 @@ if helpers.pending_win32(pending) then return end
describe('External command line completion', function()
local screen
local shown = false
- local firstc, prompt, content, pos, char, shift, level, current_hide_level
+ local firstc, prompt, content, pos, char, shift, level, current_hide_level, in_function
before_each(function()
clear()
@@ -24,6 +24,10 @@ describe('External command line completion', function()
char, shift = unpack(data)
elseif name == "cmdline_pos" then
pos = data[1]
+ elseif name == "cmdline_function_show" then
+ in_function = true
+ elseif name == "cmdline_function_hide" then
+ in_function = false
end
end)
end)
@@ -158,6 +162,39 @@ describe('External command line completion', function()
eq(1, current_hide_level)
end)
+ feed(':function Foo()<cr>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], nil, nil, function()
+ eq(true, in_function)
+ end)
+
+ feed('line1<cr>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], nil, nil, function()
+ eq(true, in_function)
+ end)
+
+ feed('endfunction<cr>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ |
+ ]], nil, nil, function()
+ eq(false, in_function)
+ end)
+
end)
end)
end)