mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51: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:
@ -140,6 +140,7 @@ describe('vim.ui_attach', function()
|
||||
{ 'lua_print', { { 0, 'message2', 0 } }, false },
|
||||
{ 'echomsg', { { 0, 'message3', 0 } }, false },
|
||||
},
|
||||
false,
|
||||
},
|
||||
}, actual, vim.inspect(actual))
|
||||
end)
|
||||
|
@ -705,12 +705,7 @@ describe('ui/ext_messages', function()
|
||||
{1:~ }|*4
|
||||
]],
|
||||
cmdline = { { abort = false } },
|
||||
msg_history = {
|
||||
{
|
||||
content = { { 'bork\nfail', 9, 6 } },
|
||||
kind = 'echoerr',
|
||||
},
|
||||
},
|
||||
msg_history = { { content = { { 'bork\nfail', 9, 6 } }, kind = 'echoerr' } },
|
||||
}
|
||||
end)
|
||||
|
||||
@ -861,10 +856,7 @@ describe('ui/ext_messages', function()
|
||||
{1:~ }|*2
|
||||
]],
|
||||
cmdline = { { abort = false } },
|
||||
msg_history = { {
|
||||
content = { { 'stuff' } },
|
||||
kind = 'echomsg',
|
||||
} },
|
||||
msg_history = { { content = { { 'stuff' } }, kind = 'echomsg' } },
|
||||
}
|
||||
end)
|
||||
|
||||
@ -1571,6 +1563,7 @@ stack traceback:
|
||||
{1:~ }|*4
|
||||
]],
|
||||
msg_history = {
|
||||
prev_cmd = true,
|
||||
{ content = { { 'foo' } }, kind = 'echo' },
|
||||
{ content = { { 'bar' } }, kind = 'echo' },
|
||||
{ content = { { 'baz' } }, kind = 'echo', append = true },
|
||||
@ -1597,10 +1590,8 @@ stack traceback:
|
||||
{1:~ }|*4
|
||||
]],
|
||||
msg_history = {
|
||||
{
|
||||
content = { { "E354: Invalid register name: '^@'", 9, 6 } },
|
||||
kind = 'emsg',
|
||||
},
|
||||
prev_cmd = true,
|
||||
{ content = { { "E354: Invalid register name: '^@'", 9, 6 } }, kind = 'emsg' },
|
||||
},
|
||||
})
|
||||
end)
|
||||
|
@ -1409,8 +1409,8 @@ function Screen:_handle_msg_ruler(msg)
|
||||
self.ruler = msg
|
||||
end
|
||||
|
||||
function Screen:_handle_msg_history_show(entries)
|
||||
self.msg_history = entries
|
||||
function Screen:_handle_msg_history_show(entries, prev_cmd)
|
||||
self.msg_history = { entries, prev_cmd }
|
||||
end
|
||||
|
||||
function Screen:_clear_block(grid, top, bot, left, right)
|
||||
@ -1510,8 +1510,8 @@ function Screen:_extstate_repr(attr_state)
|
||||
}
|
||||
end
|
||||
|
||||
local msg_history = {}
|
||||
for i, entry in ipairs(self.msg_history) do
|
||||
local msg_history = { prev_cmd = self.msg_history[2] or nil }
|
||||
for i, entry in ipairs(self.msg_history[1] or {}) do
|
||||
msg_history[i] = {
|
||||
kind = entry[1],
|
||||
content = self:_chunks_repr(entry[2], attr_state),
|
||||
|
Reference in New Issue
Block a user