Files
neovim/runtime/doc
Justin M. Keyes 25f7c87a70 fix(mappings): replaying a deleted Lua mapping is UB
Problem:
Replaying a deleted Lua mapping, may call an arbitrary function.

RHS of a Lua mapping embeds its LuaRef (`<K_LUA><ref><CR>`). The raw
keys may outlive the ref (redobuff ".", CmdAtom `keys`). If the mapping
is deleted, replaying it either (1) dereferences a freed registry slot,
or (2) calls whatever callback reused the slot (autocmd, timer, other
mapping).

Solution:
Assign a monotonic (never recycled) id to Lua mappings and encode the
mapping keys as `<K_LUA><id><CR>`.

Note: in the case of Vimscript, a deleted function raises E117, but if
the function is redefined with the same name, the mapping will find it.

Alternatives?:
- Globally ensure `LuaRef` ids are not recycled.
  - Problem: could exhaust `int` in a long-lived Nvim session? Also,
    difficult to impl bc the "recycling" is done by `luaL_ref` itself.

ref: 5ac2e47acc
2026-08-31 00:16:01 +02:00
..
2026-08-23 12:38:07 -04:00
2026-02-12 13:46:45 +01:00
2024-05-15 23:19:26 +02:00
2026-06-29 13:10:31 -04:00
2026-08-01 17:48:32 -04:00
2026-08-01 17:48:32 -04:00
2025-12-06 20:33:02 -05:00
2023-06-25 17:14:28 +02:00
2026-04-18 15:38:59 -04:00
2026-01-27 17:14:57 -05:00
2026-08-04 20:48:44 +02:00
2025-12-15 13:55:15 -05:00
2026-03-16 10:29:58 +01:00
2025-09-28 20:57:59 -07:00
2026-08-06 10:27:29 +02:00
2026-05-07 10:36:55 +02:00
2026-05-14 13:13:30 -04:00
2025-12-15 13:55:15 -05:00
2026-08-23 12:38:07 -04:00
2026-04-22 18:25:07 -04:00
2026-05-17 10:02:12 -04:00
2026-08-06 10:27:29 +02:00
2026-05-07 10:36:48 +02:00
2026-07-25 12:47:51 -04:00
2026-08-06 10:27:29 +02:00
2026-08-14 09:30:31 -04:00
2026-07-30 15:09:19 -04:00