Skip to content

Commit

Permalink
Fix table.move usage in query_cached (#173)
Browse files Browse the repository at this point in the history
* Fix table.move usage in query_cached

* Add test case
  • Loading branch information
vnnh authored Jan 5, 2025
1 parent aafafc9 commit 509048b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jecs.luau
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@ local function query_cached(query: QueryInner)
local with = query.filter_with
local ids = query.ids
if with then
table.move(ids, 1, #ids, #with, with)
table.move(ids, 1, #ids, #with + 1, with)
else
query.filter_with = ids
end
Expand Down
17 changes: 17 additions & 0 deletions test/tests.luau
Original file line number Diff line number Diff line change
Expand Up @@ -1495,5 +1495,22 @@ TEST("repro", function()
end
CHECK(counter == 1)
end

do CASE "#3" -- ISSUE #171
local world = world_new()
local component1 = world:component()
local tag1 = world:entity()

local query = world:query(component1):with(tag1):cached()

local entity = world:entity()
world:set(entity, component1, "some data")

local counter = 0
for x in query:iter() do
counter += 1
end
CHECK(counter == 0)
end
end)
FINISH()

0 comments on commit 509048b

Please sign in to comment.