aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/generators/gen_api_ui_events.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/generators/gen_api_ui_events.lua')
-rw-r--r--src/nvim/generators/gen_api_ui_events.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua
index 516b5ad5ae..3e8ae19c9a 100644
--- a/src/nvim/generators/gen_api_ui_events.lua
+++ b/src/nvim/generators/gen_api_ui_events.lua
@@ -54,7 +54,7 @@ local function call_ui_event_method(output, ev)
local kind = ev.parameters[j][1]
if kind ~= 'Object' then
if kind == 'HlAttrs' then
- kind = 'Dictionary'
+ kind = 'Dict'
end
output:write('\n || args.items[' .. (j - 1) .. '].type != kObjectType' .. kind .. '')
end
@@ -74,7 +74,7 @@ local function call_ui_event_method(output, ev)
output:write(
'ui_client_dict2hlattrs(args.items['
.. (j - 1)
- .. '].data.dictionary, '
+ .. '].data.dict, '
.. (hlattrs_args_count == 0 and 'true' or 'false')
.. ');\n'
)
@@ -128,8 +128,16 @@ for i = 1, #events do
write_signature(call_output, ev, '')
call_output:write('\n{\n')
if ev.remote_only then
+ -- Lua callbacks may emit other events or the same event again. Avoid the latter
+ -- by adding a recursion guard to each generated function that may call a Lua callback.
+ call_output:write(' static bool entered = false;\n')
+ call_output:write(' if (entered) {\n')
+ call_output:write(' return;\n')
+ call_output:write(' }\n')
+ call_output:write(' entered = true;\n')
write_arglist(call_output, ev)
call_output:write(' ui_call_event("' .. ev.name .. '", ' .. args .. ');\n')
+ call_output:write(' entered = false;\n')
elseif ev.compositor_impl then
call_output:write(' ui_comp_' .. ev.name)
write_signature(call_output, ev, '', true)
@@ -197,7 +205,8 @@ for _, ev in ipairs(events) do
ev_exported[attr] = ev[attr]
end
for _, p in ipairs(ev_exported.parameters) do
- if p[1] == 'HlAttrs' then
+ if p[1] == 'HlAttrs' or p[1] == 'Dict' then
+ -- TODO(justinmk): for back-compat, but do clients actually look at this?
p[1] = 'Dictionary'
end
end