Add region-restricted parsing and highlighting#202
Open
Conversation
c088e9e to
614d6ce
Compare
|
looking forward to this PR landing in thanks! |
Collaborator
Author
The design in this PR is intended for one-at-a-time parsing of code blocks, so I'm not sure it would help a CSS-in-JS mode (a multi-language use case). How would you use it? |
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.
This will allow
jupyter-replto integrate withtree-sitterandtree-sitter-hl. See #78 for more context.I initially tried to make
tree-sitterparse only the narrowed region. However, since tree-sitter's incremental parsing requires precisely tracking all changes to the source code, there are some issues with that approach:before-change-functionsandafter-change-functions, which can be run while narrowing is enabled for a different region than the intended region.tree-sitteritself.The design of this new functionality is instead like followed:
tree-sitterstill tracks all changes in the buffer.tree-sitterparses, it asks the major mode for the region to parse, by calling the functiontree-sitter-get-parse-regions.tree-sitter-hlhighlights the buffer, it does so only for the parsed region, while using the old region-fontification function for other regions.tree-sitter-hl-dry-up-regionto "persist" the highlighted region (now-frozen input cell).tree-sitter-pause, and thentree-sitter-resumeafterwards, to start a new, non-incremental parse.Tasks:
jupyter-replintegrationinferior-python-modeintegration