Repository navigation
fix(core): drop matches that overlap any earlier kept match in tokenize - #1460
RaphaelFakhri wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 0f0fe49 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@RaphaelFakhri is attempting to deploy a commit to the LiveKit Team on Vercel. A member of the Team first needs to authorize it. |
|
@lukasIO Can you take a look at this one? I'm not fully sure where |
|
yeah, it's an edge case but worth fixing. Changes look good |
|
Thanks for taking a look. This PR can't be reopened because its fork was deleted, so the same change is now in #1467, rebased onto current |
Summary
tokenizeremoves overlapping matches by comparing each match with the previous entry in the sorted list, not with the last match it kept. When a long match contains two or more shorter matches, the first nested match is dropped but the second one starts after it ends, so it passes the check. The output then contains the nested text a second time.For the grammar
{ outer: /abcdefghij/g, first: /cd/g, second: /gh/g }and the inputxx abcdefghij yy, the tokens join toxx abcdefghijghij yy.This change tracks the end of the last kept match and drops any match that starts before it.
Testing
tokenizer.test.tswith a basic split case and two overlap cases.mainand pass with this change.Changeset
Adds a patch changeset for
@livekit/components-core.