Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bin/omarchy-menu-keybindings
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ end

local noop
noop = setmetatable({}, {
__index = function()
__index = function(_, key)
-- API queries return empty lists: ipairs must stop at the first index.
if type(key) == "number" then
return nil
Comment on lines +213 to +214

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Direct indexing aborts scanning

If a user's Lua config accesses a field on a known-present API result, such as hl.get_workspace_windows(...)[1].title, the scanner now returns nil for [1]. The field access then errors, ending the config scan before later bindings are collected. The menu silently omits those bindings unless DEBUG=1.

Knowledge Base Used: Hyprland configuration and display control

end
return noop
end,
__call = function()
Expand Down
26 changes: 26 additions & 0 deletions test/shell.d/keybindings-menu-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,29 @@ expected=$(printf '%s\n' \
$'SUPER + X → My own thing\texec\tmy-thing')
[[ $translated == "$expected" ]] || fail "keybinding descriptions show in the Omarchy language" "$translated"
pass "keybinding descriptions show in the Omarchy language"

# The scanner's no-op API must behave like an empty list when a config queries
# loaded plugins. Keep later bindings in the fixture to catch silent scan errors.
cat >"$home/.config/hypr/hyprland.lua" <<'LUA'
hl.plugin.load("unused.so")
local plugin_count = 0
for _, plugin in ipairs(hl.get_loaded_plugins()) do
plugin_count = plugin_count + 1
end
assert(plugin_count == 0, "the scanner should not report loaded plugins")
hl.bind("SUPER + W", hl.dsp.window.close(), { description = "Close window" })
hl.bind("SUPER + Q", hl.dsp.window.close(), { description = "Close window" })
LUA

stub_hyprctl <<BINDS
$(lua_bind 64 "SUPER + W" "Close window")
$(lua_bind 64 "SUPER + Q" "Close window")
BINDS

rendered=$(env -i PATH="$stub_bin:$ROOT/bin:$PATH" HOME="$home" \
XDG_CACHE_HOME="$tmpdir/plugin-cache" OMARCHY_PATH="$ROOT" \
timeout --kill-after=1s 5s bash "$ROOT/bin/omarchy-menu-keybindings" --print) ||
fail "scanning a plugin list finishes without hanging"
grep -q 'SUPER + W / SUPER + Q *→ Close window' <<<"$rendered" ||
fail "bindings after a plugin list are still resolved" "$rendered"
pass "plugin list iteration terminates and later bindings are resolved"