aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/generators
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2024-06-04 15:09:12 +0200
committerGitHub <noreply@github.com>2024-06-04 06:09:12 -0700
commitb66106a46c5c6180c7f80852a8c822b400e73100 (patch)
tree3ea46b835fbbd014a719fdab42487385843b5225 /src/nvim/generators
parent8cbb1f20e557461c8417583a7f69d53aaaef920b (diff)
downloadrneovim-b66106a46c5c6180c7f80852a8c822b400e73100.tar.gz
rneovim-b66106a46c5c6180c7f80852a8c822b400e73100.tar.bz2
rneovim-b66106a46c5c6180c7f80852a8c822b400e73100.zip
fix(ui): superfluous showmode / excessive grid_cursor_goto #29089
Problem: Unsetting global variables earlier in #28578 to avoid recursiveness, caused superfluous or even unlimited showmode(). Solution: Partly revert #28578 so that the globals are unset at the end of showmode(), and avoid recursiveness for ext UI by adding a recursive function guard to each generated UI call that may call a Lua callback.
Diffstat (limited to 'src/nvim/generators')
-rw-r--r--src/nvim/generators/gen_api_ui_events.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua
index 516b5ad5ae..c5b37672bf 100644
--- a/src/nvim/generators/gen_api_ui_events.lua
+++ b/src/nvim/generators/gen_api_ui_events.lua
@@ -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)