Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion bin/omarchy-menu-keybindings
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,17 @@ local function dsp_proxy(path)
})
end

-- Unknown hl.* accessors fall back to a noop so simple config calls parse, but
-- a noop must read as an empty sequence: the scan is reading real user configs
-- (e.g. ones that call hl.get_loaded_plugins and iterate the result), and a
-- metatable that yields a fresh value for every numeric index makes ipairs()
-- and # spin forever. Return nil for numbers so such loops terminate.
local noop
noop = setmetatable({}, {
__index = function()
__index = function(_, key)
if type(key) == "number" then
return nil
end
return noop
end,
__call = function()
Expand Down
28 changes: 28 additions & 0 deletions test/shell.d/keybindings-menu-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,31 @@ for action in "${expected_alternatives[@]}"; do
fail "every action named as having an alternative is bound twice" "$action"
done
pass "every action named as having an alternative is bound twice"

# The menu parses real user configs under a stubbed `hl`. A config that calls a
# list accessor and walks the result (such as a border-fx style file doing
# ipairs(hl.get_loaded_plugins())) must leave the scan, not hang on a noop
# that answers a value for every numeric index.
spin_home="$tmpdir/spin-home"
mkdir -p "$spin_home/.config"
cp -r "$ROOT/config/hypr" "$spin_home/.config/hypr"

cat >"$spin_home/.config/hypr/spin.lua" <<'LUA'
local function loaded()
for _, p in ipairs(hl.get_loaded_plugins()) do
if p.name == "hypr-shiny-border" then
return true
end
end
return false
end
loaded()
LUA
printf '\npcall(require, "hypr.spin")\n' >>"$spin_home/.config/hypr/hyprland.lua"

spin_rendered=$(env -i PATH="$stub_bin:$ROOT/bin:$PATH" HOME="$spin_home" \
XDG_CACHE_HOME="$tmpdir/cache" OMARCHY_PATH="$ROOT" \
timeout 20 bash "$ROOT/bin/omarchy-menu-keybindings" --print)
[[ $? == 0 ]] ||
fail "a config iterating a stubbed hl accessor completes the scan" "$spin_rendered"
pass "a config iterating a stubbed hl accessor completes the scan"