You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
v2: spurious 'No action found for keymap' warning for function-valued window keymaps on re-registration #506
Function-valued window keymaps (e.g. a custom callback in keymap.output_window) emit a spurious warning every time window keymaps are re-processed for a buffer that already has the mapping:
No action found for keymap: <M-n> -> function: 0x...
This happens on every panel toggle (the output buffer survives, the window is recreated, setup_panel_keymaps re-runs setup_window_keymaps(..., preserve_existing=true) on the same buffer), so the warning fires repeatedly during normal use.
Then open the opencode panel, close it, and open it again — the warning appears on the second open. Equivalently, calling require('opencode.keymap').setup_window_keymaps(cfg, buf, true) twice with the same buffer reproduces it: first call is silent, second warns.
Root cause
In lua/opencode/keymap.lua, process_keymap_entry (lines 86-93):
ifcallbackand#modes>0then...vim.keymap.set(modes, key_binding, callback, opts)
elseiftype(func_name) ~='string' thenvim.notify(string.format('No action found for keymap: %s -> %s', key_binding, func_name), vim.log.levels.WARN)
end
With preserve_existing, modes for which the buffer already has the mapping are filtered out, leaving modes = {} on re-processing. For function-valued entries resolve_callback always returns the function, so callback is non-nil and the elseif is reached purely because #modes == 0 — i.e. "already registered, nothing to do", not "no action found". String actions are spared only because of the type(func_name) ~= 'string' check.
In fact the branch is only reachable for function values with empty modes (string actions either resolve or warn earlier in resolve_callback), so it only ever produces false positives.
Suggested fix
Skip silently when nothing is left to do — only warn when the callback could not be resolved:
ifcallbackand#modes>0then...vim.keymap.set(modes, key_binding, callback, opts)
elseifnotcallbackandtype(func_name) ~='string' thenvim.notify(...)
end
Confirmed fixed on latest v2 (55c994d). Calling setup_window_keymaps twice with a function-valued keymap no longer produces the spurious warning — the mapping registers once and re-registration is silent. Thanks!
Activity
sudo-tee commentedon Sep 29, 2026
@wzj-zz
The issue should be fixed now I rebased main branch which had fixed the issue
see related MR #500
Let me know if it works for you
wzj-zz commentedon Sep 30, 2026
Confirmed fixed on latest v2 (55c994d). Calling
setup_window_keymapstwice with a function-valued keymap no longer produces the spurious warning — the mapping registers once and re-registration is silent. Thanks!