(renderer) keymap bugfix
All checks were successful
NeoVim tests / code-quality (push) Successful in 1m22s
All checks were successful
NeoVim tests / code-quality (push) Successful in 1m22s
This commit is contained in:
parent
7367a71dd0
commit
fd69ebfaad
@ -1,4 +1,4 @@
|
|||||||
local Signal = require('u.tracker').Signal
|
function _G.URendererOpFuncSwallow() end
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
local H = {}
|
local H = {}
|
||||||
@ -243,12 +243,20 @@ function Renderer:render(tree) -- {{{
|
|||||||
for lhs, _ in pairs(tag.attributes[mode .. 'map'] or {}) do
|
for lhs, _ in pairs(tag.attributes[mode .. 'map'] or {}) do
|
||||||
-- Force creating an extmark if there are key handlers. To accurately
|
-- Force creating an extmark if there are key handlers. To accurately
|
||||||
-- sense the bounds of the text, we need an extmark:
|
-- sense the bounds of the text, we need an extmark:
|
||||||
vim.keymap.set(
|
vim.keymap.set(mode, lhs, function()
|
||||||
mode,
|
local result = self:_expr_map_callback(mode, lhs)
|
||||||
lhs,
|
-- If the handler indicates that it wants to swallow the event,
|
||||||
function() return self:_expr_map_callback(mode, lhs) end,
|
-- we have to convert that intention into something compatible
|
||||||
{ buffer = self.bufnr, expr = true, replace_keycodes = true }
|
-- with expr-mappings, which don't support '<Nop>' (they try to
|
||||||
)
|
-- execute the literal characters). We'll use the 'g@' operator
|
||||||
|
-- to do that, forwarding the event to an operatorfunc that does
|
||||||
|
-- nothing:
|
||||||
|
if result == '' then
|
||||||
|
vim.go.operatorfunc = 'v:lua.URendererOpFuncSwallow'
|
||||||
|
return 'g@ '
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end, { buffer = self.bufnr, expr = true, replace_keycodes = true })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -509,7 +517,7 @@ function TreeBuilder:put_h(name, attributes, children)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param fn fun(TreeBuilder): any
|
--- @param fn fun(tb: u.renderer.TreeBuilder): any
|
||||||
--- @return u.renderer.TreeBuilder
|
--- @return u.renderer.TreeBuilder
|
||||||
function TreeBuilder:nest(fn)
|
function TreeBuilder:nest(fn)
|
||||||
local nested_writer = TreeBuilder.new()
|
local nested_writer = TreeBuilder.new()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user