mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #13729 from devbhansingh/ui_enter_prompt
feat(ui): clear message history explicitly with msg_history_clear event
This commit is contained in:
commit
cbf0360179
@ -174,4 +174,6 @@ void msg_ruler(Array content)
|
|||||||
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY;
|
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY;
|
||||||
void msg_history_show(Array entries)
|
void msg_history_show(Array entries)
|
||||||
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY;
|
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY;
|
||||||
|
void msg_history_clear(void)
|
||||||
|
FUNC_API_SINCE(10) FUNC_API_REMOTE_ONLY;
|
||||||
#endif // NVIM_API_UI_EVENTS_IN_H
|
#endif // NVIM_API_UI_EVENTS_IN_H
|
||||||
|
@ -125,6 +125,8 @@ static size_t msg_ext_cur_len = 0;
|
|||||||
static bool msg_ext_overwrite = false; ///< will overwrite last message
|
static bool msg_ext_overwrite = false; ///< will overwrite last message
|
||||||
static int msg_ext_visible = 0; ///< number of messages currently visible
|
static int msg_ext_visible = 0; ///< number of messages currently visible
|
||||||
|
|
||||||
|
static bool msg_ext_history_visible = false;
|
||||||
|
|
||||||
/// Shouldn't clear message after leaving cmdline
|
/// Shouldn't clear message after leaving cmdline
|
||||||
static bool msg_ext_keep_after_cmdline = false;
|
static bool msg_ext_keep_after_cmdline = false;
|
||||||
|
|
||||||
@ -1025,6 +1027,9 @@ void ex_messages(void *const eap_p)
|
|||||||
|
|
||||||
// Display what was not skipped.
|
// Display what was not skipped.
|
||||||
if (ui_has(kUIMessages)) {
|
if (ui_has(kUIMessages)) {
|
||||||
|
if (msg_silent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Array entries = ARRAY_DICT_INIT;
|
Array entries = ARRAY_DICT_INIT;
|
||||||
for (; p != NULL; p = p->next) {
|
for (; p != NULL; p = p->next) {
|
||||||
if (p->msg != NULL && p->msg[0] != NUL) {
|
if (p->msg != NULL && p->msg[0] != NUL) {
|
||||||
@ -1040,6 +1045,8 @@ void ex_messages(void *const eap_p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui_call_msg_history_show(entries);
|
ui_call_msg_history_show(entries);
|
||||||
|
msg_ext_history_visible = true;
|
||||||
|
wait_return(false);
|
||||||
} else {
|
} else {
|
||||||
msg_hist_off = true;
|
msg_hist_off = true;
|
||||||
for (; p != NULL && !got_int; p = p->next) {
|
for (; p != NULL && !got_int; p = p->next) {
|
||||||
@ -3126,6 +3133,10 @@ void msg_ext_clear(bool force)
|
|||||||
msg_ext_visible = 0;
|
msg_ext_visible = 0;
|
||||||
msg_ext_overwrite = false; // nothing to overwrite
|
msg_ext_overwrite = false; // nothing to overwrite
|
||||||
}
|
}
|
||||||
|
if (msg_ext_history_visible) {
|
||||||
|
ui_call_msg_history_clear();
|
||||||
|
msg_ext_history_visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Only keep once.
|
// Only keep once.
|
||||||
msg_ext_keep_after_cmdline = false;
|
msg_ext_keep_after_cmdline = false;
|
||||||
|
@ -304,13 +304,25 @@ describe('ui/ext_messages', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
]], messages={
|
]], msg_history={
|
||||||
{kind="echoerr", content={{"raa", 2}}},
|
{kind="echoerr", content={{"raa", 2}}},
|
||||||
{kind="echoerr", content={{"bork", 2}}},
|
{kind="echoerr", content={{"bork", 2}}},
|
||||||
{kind="echoerr", content={{"fail", 2}}},
|
{kind="echoerr", content={{"fail", 2}}},
|
||||||
{kind="echoerr", content={{"extrafail", 2}}},
|
{kind="echoerr", content={{"extrafail", 2}}},
|
||||||
{kind="echoerr", content={{"problem", 2}}}
|
{kind="echoerr", content={{"problem", 2}}}
|
||||||
}}
|
}, messages={{
|
||||||
|
content = {{ "Press ENTER or type command to continue", 4 }},
|
||||||
|
kind = "return_prompt"
|
||||||
|
}}}
|
||||||
|
|
||||||
|
feed '<cr>'
|
||||||
|
screen:expect{grid=[[
|
||||||
|
^ |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
]]}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('shortmess-=S', function()
|
it('shortmess-=S', function()
|
||||||
@ -455,11 +467,14 @@ describe('ui/ext_messages', function()
|
|||||||
alphpabe^t |
|
alphpabe^t |
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
]], messages={
|
]], msg_history={{
|
||||||
{kind="echomsg", content={{"stuff"}}},
|
content = {{ "stuff" }},
|
||||||
}, showmode={
|
kind = "echomsg",
|
||||||
{ "-- INSERT --", 3 }
|
}}, showmode={{ "-- INSERT --", 3 }},
|
||||||
}}
|
messages={{
|
||||||
|
content = {{ "Press ENTER or type command to continue", 4}},
|
||||||
|
kind = "return_prompt"
|
||||||
|
}}}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('&showmode with macro-recording message', function()
|
it('&showmode with macro-recording message', function()
|
||||||
@ -685,12 +700,15 @@ describe('ui/ext_messages', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
]], messages={
|
]], msg_history={
|
||||||
{kind="echomsg", content={{"howdy"}}},
|
{kind="echomsg", content={{"howdy"}}},
|
||||||
{kind="", content={{"Type :qa and press <Enter> to exit Nvim"}}},
|
{kind="", content={{"Type :qa and press <Enter> to exit Nvim"}}},
|
||||||
{kind="echoerr", content={{"bork", 2}}},
|
{kind="echoerr", content={{"bork", 2}}},
|
||||||
{kind="emsg", content={{"E117: Unknown function: nosuchfunction", 2}}}
|
{kind="emsg", content={{"E117: Unknown function: nosuchfunction", 2}}}
|
||||||
}}
|
}, messages={{
|
||||||
|
content = {{ "Press ENTER or type command to continue", 4}},
|
||||||
|
kind = "return_prompt"
|
||||||
|
}}}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implies ext_cmdline and ignores cmdheight', function()
|
it('implies ext_cmdline and ignores cmdheight', function()
|
||||||
|
@ -242,7 +242,7 @@ end
|
|||||||
-- canonical order of ext keys, used to generate asserts
|
-- canonical order of ext keys, used to generate asserts
|
||||||
local ext_keys = {
|
local ext_keys = {
|
||||||
'popupmenu', 'cmdline', 'cmdline_block', 'wildmenu_items', 'wildmenu_pos',
|
'popupmenu', 'cmdline', 'cmdline_block', 'wildmenu_items', 'wildmenu_pos',
|
||||||
'messages', 'showmode', 'showcmd', 'ruler', 'float_pos', 'win_viewport'
|
'messages', 'msg_history', 'showmode', 'showcmd', 'ruler', 'float_pos', 'win_viewport'
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Asserts that the screen state eventually matches an expected state.
|
-- Asserts that the screen state eventually matches an expected state.
|
||||||
@ -1083,6 +1083,10 @@ function Screen:_handle_msg_history_show(entries)
|
|||||||
self.msg_history = entries
|
self.msg_history = entries
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Screen:_handle_msg_history_clear()
|
||||||
|
self.msg_history = {}
|
||||||
|
end
|
||||||
|
|
||||||
function Screen:_clear_block(grid, top, bot, left, right)
|
function Screen:_clear_block(grid, top, bot, left, right)
|
||||||
for i = top, bot do
|
for i = top, bot do
|
||||||
self:_clear_row_section(grid, i, left, right)
|
self:_clear_row_section(grid, i, left, right)
|
||||||
@ -1171,7 +1175,7 @@ function Screen:_extstate_repr(attr_state)
|
|||||||
|
|
||||||
local msg_history = {}
|
local msg_history = {}
|
||||||
for i, entry in ipairs(self.msg_history) do
|
for i, entry in ipairs(self.msg_history) do
|
||||||
messages[i] = {kind=entry[1], content=self:_chunks_repr(entry[2], attr_state)}
|
msg_history[i] = {kind=entry[1], content=self:_chunks_repr(entry[2], attr_state)}
|
||||||
end
|
end
|
||||||
|
|
||||||
local win_viewport = (next(self.win_viewport) and self.win_viewport) or nil
|
local win_viewport = (next(self.win_viewport) and self.win_viewport) or nil
|
||||||
|
Loading…
Reference in New Issue
Block a user