Skip to content

fix: inverted push direction#955

Open
ChargeIn wants to merge 1 commit intotiberiuzuld:masterfrom
ChargeIn:933
Open

fix: inverted push direction#955
ChargeIn wants to merge 1 commit intotiberiuzuld:masterfrom
ChargeIn:933

Conversation

@ChargeIn
Copy link
Contributor

Hey, I was trying to fix #933.

What I notices is that the grid starts a recursive chain to pushes all items to the north and once it hit the border it works it self back from the top checking all the other possible solutions -> Leading to Number 1 being pushed down by Number 2 creating the swap effect.

There are multiple solution how this could be solved. E.g. we could track if the push would collide with there chained pushed coming from the opposite direction.

But I was wondering what is the use case for this last check? In the code you are checking for swap in a separate function so there should not really be a need to check for a push in the direction you are coming from.

Can you please give a small example? Otherwise the code attach will fix the issue.

I create a patch file to test the issue. After applying you can find the test view under the path "/test"
add_test_view.patch

@tiberiuzuld
Copy link
Owner

Hi @ChargeIn ,
From what I remember the use case for the recursive check of direction of push is that if you have a limited grid, let's say a 4x4 grid limited with maxRows and maxCols. So when one item is moved the other 3 need to spin like a clock around the grid.

Don't think if we make the proposed changes will this corner case still work.

@ChargeIn
Copy link
Contributor Author

ChargeIn commented Jan 28, 2026

Hey, thanks for the review. I think the edge case will still work.

The reason is that I only took way the "check" to push directly back to the direction you are coming from. In the case you are described we will check recursively and with each recursion the direction is different so it should not be effected.

Screencast.From.2026-01-28.22-30-28.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug with swapping items

2 participants