Open
Conversation
Owner
blake-mealey
left a comment
There was a problem hiding this comment.
Thanks for the PR! Added a comment
src/parser.ts
Outdated
| foreground, | ||
| background, | ||
| decorations: new Set(decorations), | ||
| offset: position, |
Owner
There was a problem hiding this comment.
This will be the position of the current parse call, but not the beginning of the full input if it is being parsed in chunks. I think the offset should be maintained at the parser level
Owner
|
Also please add some tests |
40a3062 to
7b61c1f
Compare
7b61c1f to
cb67ea6
Compare
Author
Agreed, updated the code.
Added a chunk test and updated other test snapshots, let me know if it's sufficient. |
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.
Description
Adds an
offsetvalue to parsed tokens for easier post-processing by being able to find the strings in the source text.I plan to integrate this into https://github.com/shikijs/shiki/blob/f8ef446af3f5f3910131b692e0c81ce032754ffa/packages/core/src/highlight/code-to-tokens-ansi.ts#L62 once it gets merged.
Changes
offsettoParseToken