Fixes #9801. Save prevResult when it is a Position #9802
Merged
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.
What this PR does / why we need it:
Make counted motions work when the result type is
Positionand the count is high enough that the motion fails eventually.For motions with a count (e.g.,
3[{), save the previous iteration's result when that result is aPosition.With a motion like
99[{, eventually (in typical files), an iteration will fail to find an unmatched { and therefore returnprevResult. However,<count>[{returns results of typePosition, and therefore,prevResultwas not being updated for it. This causedexecActionWithCountto returnprevResult's initial value offailedMovement. This in turn led to the cursor not moving at all, when it should have moved to the last unmatched {, i.e., thePositionof the last successful iteration.This commit fixes this issue by making sure
prevResultis updated when result is aPosition.Which issue(s) this PR fixes
#9801
Special notes for your reviewer:
I don't actually know if it is intentional or not that
prevResultwas only updated whenresultwas anIMovement. I hope I am not introducing wrong behavior with this. Hopefully the reviewer will know.I tried writing test cases for this behavior, but I couldn't see how to call an action with a count from within the tests, so I have given up on it for now.