Skip to content

fix: correct loop increment in move-limiting logic#12129

Open
nisshchayarathi wants to merge 2 commits intoopenstreetmap:developfrom
nisshchayarathi:fix/move-limit-loop-increment
Open

fix: correct loop increment in move-limiting logic#12129
nisshchayarathi wants to merge 2 commits intoopenstreetmap:developfrom
nisshchayarathi:fix/move-limit-loop-increment

Conversation

@nisshchayarathi
Copy link
Copy Markdown
Contributor

Fixes #12128

Description

This PR fixes an issue in the move-limiting logic where the inner loop was incrementing the wrong variable, leading to incorrect iteration behavior.

Changes

  • Corrected the loop increment variable

Testing

  • Verified behavior manually
  • Ran existing test suite to ensure no regressions

@nisshchayarathi

This comment was marked as off-topic.

@matkoniecz
Copy link
Copy Markdown
Contributor

  1. pinging maintainers is not needed
  2. have you tested is it working add intended by testing whether program runs as intended by using specific code?

Note that tests also passed before, so this specific functionality is not tested at all - so tests passing does not indicate much

@nisshchayarathi
Copy link
Copy Markdown
Contributor Author

@matkoniecz the var j is defined and in for loop i is getting incremented obviously it needs to be fixed

@matkoniecz
Copy link
Copy Markdown
Contributor

Yes, but fix needs to be tested.

In some cases multiple bugs were masking each other, and fixing just one of them would make situation worse.

Also, testing may reveal more problems with code here. If such mistake exists then surely something went quite wrong.

Copy link
Copy Markdown
Member

@tyrasd tyrasd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does seem like an actual mistake in the for loop variable. See 9b200cf#diff-e1e4ae664eecbe2722b4542db88173ce69c14f939d89784c0ad32a61dc0d6451R296

Luckily, there are not too many cases where hits will have more than one entry, so that's probably why it wasn't causing much troubles in practice.

However, as mentioned by @matkoniecz: we should definitely add a unit test that checks that the method is working as intended. For this we need to create a test case where movedPath and unmovedPath meet in two points.

@tyrasd tyrasd added bug A bug - let's fix this! operation An editing operation / edit menu item labels Mar 30, 2026
@nisshchayarathi nisshchayarathi requested a review from tyrasd March 30, 2026 13:32
Comment thread test/spec/actions/move.js
});
});

it('limits delta when movedPath and unmovedPath intersect twice', function() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test does not fail in the current implementation (without the bug fix). Please construct a test that actually fails in the current development branch, and is fixed in the PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sir I checked
it fails without the fix: the buggy loop ,increments the outer i inside the inner loop, so it skips the later intersection object that actually constrains the x movement.

Screenshot 2026-03-31 153254

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am missing something please suggest

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

Labels

bug A bug - let's fix this! operation An editing operation / edit menu item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect loop increment in move-limiting logic

3 participants