Skip to content

refactor(lua): extract lua_callback_factory for register_* activation closures - #400

Merged
Kohei-Wada merged 1 commit into
mainfrom
refactor/register-callback-factory
Jul 24, 2026
Merged

refactor(lua): extract lua_callback_factory for register_* activation closures#400
Kohei-Wada merged 1 commit into
mainfrom
refactor/register-callback-factory

Conversation

@Kohei-Wada

Copy link
Copy Markdown
Owner

Closes #314.

Both register_palette_command and register_keybind built the same activation closure inline: fetch the callback from the Lua registry, call it, log::warn! + swallow on error. Extracted lua_callback_factory(lua, key, tag) -> SpawnComponent; the Rc<RegistryKey> wrapper is gone since the factory closure is now the key's sole owner.

🤖 Generated with Claude Code

https://claude.ai/code/session_019Ktx7C4Zf26MhQABaPNYze

… closures

register_palette_command / register_keybind built the same
fetch-from-registry + call + warn-on-error closure inline. One helper,
both sites delegate; the Rc around RegistryKey goes away since the
factory is now the key's sole owner.

Closes #314

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactoring successfully extracts duplicated activation closure logic into a shared lua_callback_factory function. The changes eliminate ~40 lines of duplicate code while maintaining the same functionality. The removal of the Rc<RegistryKey> wrapper is safe since mlua's RegistryKey Drop implementation handles automatic cleanup when the closure is dropped. No blocking issues identified.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@Kohei-Wada
Kohei-Wada merged commit 0131f97 into main Jul 24, 2026
5 checks passed
@Kohei-Wada
Kohei-Wada deleted the refactor/register-callback-factory branch July 24, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(lua): extract register_* factory helper

1 participant