Add region-restricted parsing and highlighting #202
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-repl
to integrate withtree-sitter
andtree-sitter-hl
. See #78 for more context.I initially tried to make
tree-sitter
parse 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-functions
andafter-change-functions
, which can be run while narrowing is enabled for a different region than the intended region.tree-sitter
itself.The design of this new functionality is instead like followed:
tree-sitter
still tracks all changes in the buffer.tree-sitter
parses, it asks the major mode for the region to parse, by calling the functiontree-sitter-get-parse-regions
.tree-sitter-hl
highlights 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-region
to "persist" the highlighted region (now-frozen input cell).tree-sitter-pause
, and thentree-sitter-resume
afterwards, to start a new, non-incremental parse.Tasks:
jupyter-repl
integrationinferior-python-mode
integration