mirror of
https://github.com/neovim/neovim.git
synced 2026-05-04 21:15:09 +00:00
feat(ui): specify whether msg_show event comes from typed command
Problem: Unable to tell whether a msg_show event is emitted as a result
a command typed on the cmdline (UI may want to represent these
differently from other messages).
Solution: Add trigger parameter that is set to "typed_cmd" for
a message emitted due to an interactively typed command.
Possible extensions are mapping/timer/event but it's hard to
imagine a UI distinguishing those so not added here.
This commit is contained in:
@@ -671,7 +671,7 @@ screen:redraw_debug() to show all intermediate screen states.]]
|
||||
-- the ext_ feature being disabled, or the feature currently not activated
|
||||
-- (e.g. no external cmdline visible). Some extensions require
|
||||
-- preprocessing to represent highlights in a reproducible way.
|
||||
local extstate = self:_extstate_repr(attr_state)
|
||||
local extstate = self:_extstate_repr(attr_state, expected)
|
||||
if expected.mode ~= nil then
|
||||
extstate.mode = self.mode
|
||||
end
|
||||
@@ -1440,7 +1440,7 @@ function Screen:_handle_wildmenu_hide()
|
||||
self.wildmenu_items, self.wildmenu_pos = nil, nil
|
||||
end
|
||||
|
||||
function Screen:_handle_msg_show(kind, chunks, replace_last, history, append, id, progress)
|
||||
function Screen:_handle_msg_show(kind, chunks, replace_last, history, append, id, trigger)
|
||||
local pos = #self.messages
|
||||
if not replace_last or pos == 0 then
|
||||
pos = pos + 1
|
||||
@@ -1451,7 +1451,7 @@ function Screen:_handle_msg_show(kind, chunks, replace_last, history, append, id
|
||||
history = history,
|
||||
append = append,
|
||||
id = id,
|
||||
progress = progress,
|
||||
trigger = trigger,
|
||||
}
|
||||
end
|
||||
|
||||
@@ -1560,7 +1560,7 @@ local function hl_id_to_name(self, id)
|
||||
return id and self.hl_names[id] or nil
|
||||
end
|
||||
|
||||
function Screen:_extstate_repr(attr_state)
|
||||
function Screen:_extstate_repr(attr_state, exp)
|
||||
local cmdline = {}
|
||||
for i, entry in pairs(self.cmdline) do
|
||||
entry = shallowcopy(entry)
|
||||
@@ -1578,13 +1578,18 @@ function Screen:_extstate_repr(attr_state)
|
||||
|
||||
local messages = {}
|
||||
for i, entry in ipairs(self.messages) do
|
||||
local trigger = nil
|
||||
if exp and exp.messages and exp.messages[i] and exp.messages[i].trigger ~= nil then
|
||||
-- Late addition, only include when expected state includes it.
|
||||
trigger = entry.trigger
|
||||
end
|
||||
messages[i] = {
|
||||
kind = entry.kind,
|
||||
content = self:_chunks_repr(entry.content, attr_state),
|
||||
history = entry.history or nil,
|
||||
append = entry.append or nil,
|
||||
id = entry.kind == 'progress' and entry.id or nil,
|
||||
progress = entry.kind == 'progress' and entry.progress or nil,
|
||||
trigger = trigger,
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user