Skip to content

Commit

Permalink
fix: assign key to group without one
Browse files Browse the repository at this point in the history
  • Loading branch information
lucobellic committed Sep 1, 2024
1 parent 768b51c commit 069fce6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lua/edgy-group/stl/cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function Cache:get_available_keys(groups)
end

-- Build picking keys for each positions and group and associate them to the group
-- Assign a pick key to group without one
---@private
---@param groups table<Edgy.Pos, EdgyGroup.IndexedGroups>
function Cache:build_keys(groups)
Expand All @@ -63,7 +64,11 @@ function Cache:build_keys(groups)
self.pick_keys[pos] = {}
for i, group in ipairs(groups[pos] and groups[pos].groups or {}) do
-- Get the next available key or use the user defined one
local key = group.pick_key or table.remove(available_keys, 1)
local key = group.pick_key
if not key then
key = table.remove(available_keys, 1)
group.pick_key = key
end

-- Save the key for the group position and index
self.pick_keys[pos][i] = key
Expand Down

0 comments on commit 069fce6

Please sign in to comment.