Repository navigation
test(find): pin where a mark lands when whitespace collapses - #988
Merged
Merged
Conversation
findText.ts works out the drawn text with one replace and the offsets back into each node with a separate loop. The existing whitespace test only counted matches, so the two could drift apart and put the highlight on the wrong characters while staying green. This asserts the marked text for collapsed runs, a dropped leading space and text after a visible break.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 is
A follow-up to #984.
findText.tsworks out each node's drawn text with onereplace(/\s+/g, ' ')and, for the nodes a match reaches, the offsets back into the node with a separate loop. The two passes encode the same collapse rule. If they drifted apart, the highlight would land on the wrong characters while the match count stayed right, and the existing whitespace test only checked the count.The new test asserts the marked text for collapsed whitespace runs, a leading space dropped after a node that already ends in one, and text after a visible
<br>.Tests
Two drifts were introduced in
offsetsOfin turn: ignoringdropLead, and not collapsing whitespace. Each turns the new test red while the other 8 stay green.Verification
513 vitest tests pass. Test-only change.