mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 16:28:17 +00:00
ext_cmdline: Add function block support
This commit is contained in:

committed by
Björn Linse

parent
866dadaf75
commit
461ae69824
@@ -75,5 +75,9 @@ void cmdline_char(String c, Integer shift, Integer level)
|
|||||||
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
|
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
|
||||||
void cmdline_hide(Integer level)
|
void cmdline_hide(Integer level)
|
||||||
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
|
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
|
#endif // NVIM_API_UI_EVENTS_IN_H
|
||||||
|
@@ -19816,6 +19816,10 @@ void ex_function(exarg_T *eap)
|
|||||||
goto errret_2;
|
goto errret_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ui_is_external(kUICmdline)) {
|
||||||
|
ui_call_cmdline_function_show();
|
||||||
|
}
|
||||||
|
|
||||||
// find extra arguments "range", "dict", "abort" and "closure"
|
// find extra arguments "range", "dict", "abort" and "closure"
|
||||||
for (;; ) {
|
for (;; ) {
|
||||||
p = skipwhite(p);
|
p = skipwhite(p);
|
||||||
@@ -19868,7 +19872,9 @@ void ex_function(exarg_T *eap)
|
|||||||
if (!eap->skip && did_emsg)
|
if (!eap->skip && did_emsg)
|
||||||
goto erret;
|
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;
|
cmdline_row = msg_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20194,6 +20200,9 @@ ret_free:
|
|||||||
xfree(name);
|
xfree(name);
|
||||||
did_emsg |= saved_did_emsg;
|
did_emsg |= saved_did_emsg;
|
||||||
need_wait_return |= saved_wait_return;
|
need_wait_return |= saved_wait_return;
|
||||||
|
if (ui_is_external(kUICmdline)) {
|
||||||
|
ui_call_cmdline_function_hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a function name, translating "<SID>" and "<SNR>".
|
/// Get a function name, translating "<SID>" and "<SNR>".
|
||||||
|
@@ -7,7 +7,7 @@ if helpers.pending_win32(pending) then return end
|
|||||||
describe('External command line completion', function()
|
describe('External command line completion', function()
|
||||||
local screen
|
local screen
|
||||||
local shown = false
|
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()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
@@ -24,6 +24,10 @@ describe('External command line completion', function()
|
|||||||
char, shift = unpack(data)
|
char, shift = unpack(data)
|
||||||
elseif name == "cmdline_pos" then
|
elseif name == "cmdline_pos" then
|
||||||
pos = data[1]
|
pos = data[1]
|
||||||
|
elseif name == "cmdline_function_show" then
|
||||||
|
in_function = true
|
||||||
|
elseif name == "cmdline_function_hide" then
|
||||||
|
in_function = false
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -158,6 +162,39 @@ describe('External command line completion', function()
|
|||||||
eq(1, current_hide_level)
|
eq(1, current_hide_level)
|
||||||
end)
|
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)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user