fix: bump initiator group in an orthogonal direction from neighboring group #8613
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The basics
The details
Resolves
Fixes #8168
Proposed Changes
When two connections that are compatible but are not connected to each other are close enough to trigger a bump, the direction to bump in now depends on whether the inferior connection is part of the "initiator" group. Previously, if they were both movable, the inferior connection would always be bumped down and right. Now, it could be bumped up and right if the inferior connection is in the initiating group, meaning the group that was manipulated most recently, causing its input neighbors to be checked for bumping.
I also refactored related logic for readability and codified the existing invariant that the parameter to the bump function is the superior connection.
Reason for Changes
It's possible for two independent groups of connected blocks to have multiple neighboring pairs of connections that can bump each other. It's further possible that both groups can have an inferior connection that would be bumped by the other group's connection. #8168 demonstrates such a scenario, where the
logic_operation
block's inferior output connection is bumped by the outercontrols_if
, which moves it downward and puts its superior input connection near thelogic_compare
block's output connection, resulting in the other group getting bumped. This all happens instantaneously, and results in both groups of blocks moving down and right, lining both of them up again to get bumped the next time bumping is triggered.It is important that the two groups get bumped in orthogonal directions to make sure they get separated in the end, but the connection type is not enough information to distinguish the groups of blocks. Instead, I designated one group the initiator, and that group gets moved in a different direction.
Test Coverage
All existing unit tests pass (except for 4 test methods that were already failing due to coordinates being slightly different when testing on my mac). I manually tested that the linked bug is avoided by this PR.
Documentation
N/A
Additional Information
N/A