mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
feat(messages): add "prev_cmd" argument to msg_history_show (#34779)
Problem: Unable to tell whether msg_history_show event is emitted for a :messages or g< command. Solution: Add "prev_cmd" argument that is set to true for g<.
This commit is contained in:
@ -72,6 +72,7 @@ EVENTS
|
|||||||
emitted after the screen is cleared. These events arbitrarily assumed a
|
emitted after the screen is cleared. These events arbitrarily assumed a
|
||||||
message UI that mimicks the legacy message grid. Benefit: reduced UI event
|
message UI that mimicks the legacy message grid. Benefit: reduced UI event
|
||||||
traffic and more flexibility for UIs.
|
traffic and more flexibility for UIs.
|
||||||
|
The `msg_history_show` event has an additional "prev_cmd" argument.
|
||||||
• A new `empty` message kind is emitted for an empty (e.g. `:echo ""`) message.
|
• A new `empty` message kind is emitted for an empty (e.g. `:echo ""`) message.
|
||||||
|
|
||||||
HIGHLIGHTS
|
HIGHLIGHTS
|
||||||
|
@ -893,8 +893,11 @@ must handle.
|
|||||||
statusline. `content` has the same format as in "msg_show". This event is
|
statusline. `content` has the same format as in "msg_show". This event is
|
||||||
sent with empty `content` to hide the last message.
|
sent with empty `content` to hide the last message.
|
||||||
|
|
||||||
["msg_history_show", entries] ~
|
["msg_history_show", entries, prev_cmd] ~
|
||||||
Sent when |:messages| command is invoked. History is sent as a list of
|
Sent when |:messages| or |g<| command is invoked. History is sent as a
|
||||||
entries, where each entry is a `[kind, content, append]` tuple.
|
list of entries, where each entry is a `[kind, content, append]` tuple.
|
||||||
|
|
||||||
|
prev_cmd
|
||||||
|
True when sent with |g<| command, false with |:messages|.
|
||||||
|
|
||||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
@ -172,7 +172,7 @@ void msg_showmode(Array content)
|
|||||||
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY;
|
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY;
|
||||||
void msg_ruler(Array content)
|
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, Boolean prev_cmd)
|
||||||
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY;
|
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY;
|
||||||
|
|
||||||
// This UI event is currently undocumented.
|
// This UI event is currently undocumented.
|
||||||
|
@ -1212,7 +1212,7 @@ void ex_messages(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (kv_size(entries) > 0) {
|
if (kv_size(entries) > 0) {
|
||||||
ui_call_msg_history_show(entries);
|
ui_call_msg_history_show(entries, eap->skip != 0);
|
||||||
api_free_array(entries);
|
api_free_array(entries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,7 @@ describe('vim.ui_attach', function()
|
|||||||
{ 'lua_print', { { 0, 'message2', 0 } }, false },
|
{ 'lua_print', { { 0, 'message2', 0 } }, false },
|
||||||
{ 'echomsg', { { 0, 'message3', 0 } }, false },
|
{ 'echomsg', { { 0, 'message3', 0 } }, false },
|
||||||
},
|
},
|
||||||
|
false,
|
||||||
},
|
},
|
||||||
}, actual, vim.inspect(actual))
|
}, actual, vim.inspect(actual))
|
||||||
end)
|
end)
|
||||||
|
@ -705,12 +705,7 @@ describe('ui/ext_messages', function()
|
|||||||
{1:~ }|*4
|
{1:~ }|*4
|
||||||
]],
|
]],
|
||||||
cmdline = { { abort = false } },
|
cmdline = { { abort = false } },
|
||||||
msg_history = {
|
msg_history = { { content = { { 'bork\nfail', 9, 6 } }, kind = 'echoerr' } },
|
||||||
{
|
|
||||||
content = { { 'bork\nfail', 9, 6 } },
|
|
||||||
kind = 'echoerr',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -861,10 +856,7 @@ describe('ui/ext_messages', function()
|
|||||||
{1:~ }|*2
|
{1:~ }|*2
|
||||||
]],
|
]],
|
||||||
cmdline = { { abort = false } },
|
cmdline = { { abort = false } },
|
||||||
msg_history = { {
|
msg_history = { { content = { { 'stuff' } }, kind = 'echomsg' } },
|
||||||
content = { { 'stuff' } },
|
|
||||||
kind = 'echomsg',
|
|
||||||
} },
|
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -1571,6 +1563,7 @@ stack traceback:
|
|||||||
{1:~ }|*4
|
{1:~ }|*4
|
||||||
]],
|
]],
|
||||||
msg_history = {
|
msg_history = {
|
||||||
|
prev_cmd = true,
|
||||||
{ content = { { 'foo' } }, kind = 'echo' },
|
{ content = { { 'foo' } }, kind = 'echo' },
|
||||||
{ content = { { 'bar' } }, kind = 'echo' },
|
{ content = { { 'bar' } }, kind = 'echo' },
|
||||||
{ content = { { 'baz' } }, kind = 'echo', append = true },
|
{ content = { { 'baz' } }, kind = 'echo', append = true },
|
||||||
@ -1597,10 +1590,8 @@ stack traceback:
|
|||||||
{1:~ }|*4
|
{1:~ }|*4
|
||||||
]],
|
]],
|
||||||
msg_history = {
|
msg_history = {
|
||||||
{
|
prev_cmd = true,
|
||||||
content = { { "E354: Invalid register name: '^@'", 9, 6 } },
|
{ content = { { "E354: Invalid register name: '^@'", 9, 6 } }, kind = 'emsg' },
|
||||||
kind = 'emsg',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
@ -1409,8 +1409,8 @@ function Screen:_handle_msg_ruler(msg)
|
|||||||
self.ruler = msg
|
self.ruler = msg
|
||||||
end
|
end
|
||||||
|
|
||||||
function Screen:_handle_msg_history_show(entries)
|
function Screen:_handle_msg_history_show(entries, prev_cmd)
|
||||||
self.msg_history = entries
|
self.msg_history = { entries, prev_cmd }
|
||||||
end
|
end
|
||||||
|
|
||||||
function Screen:_clear_block(grid, top, bot, left, right)
|
function Screen:_clear_block(grid, top, bot, left, right)
|
||||||
@ -1510,8 +1510,8 @@ function Screen:_extstate_repr(attr_state)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local msg_history = {}
|
local msg_history = { prev_cmd = self.msg_history[2] or nil }
|
||||||
for i, entry in ipairs(self.msg_history) do
|
for i, entry in ipairs(self.msg_history[1] or {}) do
|
||||||
msg_history[i] = {
|
msg_history[i] = {
|
||||||
kind = entry[1],
|
kind = entry[1],
|
||||||
content = self:_chunks_repr(entry[2], attr_state),
|
content = self:_chunks_repr(entry[2], attr_state),
|
||||||
|
Reference in New Issue
Block a user