Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select subtree within injections in :tree-sitter-subtree #9309

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

the-mikedavis
Copy link
Member

:tree-sitter-subtree could previously only print subtrees of nodes in the root injection layer. We can improve on that by finding the layer that contains the given byte range and printing the subtree within that layer. That gives more useful results when a selection is within an injection layer.

For example in a markdown file:

One

<h1>
<div>
<p>Foo</p>
</div>

Two

<div>
<p>Bar</p>
</div>
</h1>

Three

Selecting the overall document will show the root layer's subtree while selecting a part within the injections like <p>Foo</p> will show that subtree within the HTML layer. This works even with combined injections, for example selecting around the h1 tags.

`:tree-sitter-subtree` could previously only print subtrees of nodes
in the root injection layer. We can improve on that by finding the layer
that contains the given byte range and printing the subtree within that
layer. That gives more useful results when a selection is within an
injection layer.
@the-mikedavis the-mikedavis added C-enhancement Category: Improvements A-tree-sitter Area: Tree-sitter S-waiting-on-review Status: Awaiting review from a maintainer. labels Jan 10, 2024
@archseer archseer merged commit eca3ccf into master Jan 15, 2024
6 checks passed
@archseer archseer deleted the tree-sitter-subtree-within-injections branch January 15, 2024 06:34
hamrik pushed a commit to hamrik/helix that referenced this pull request Jan 27, 2024
…r#9309)

`:tree-sitter-subtree` could previously only print subtrees of nodes
in the root injection layer. We can improve on that by finding the layer
that contains the given byte range and printing the subtree within that
layer. That gives more useful results when a selection is within an
injection layer.
dgkf pushed a commit to dgkf/helix that referenced this pull request Jan 30, 2024
…r#9309)

`:tree-sitter-subtree` could previously only print subtrees of nodes
in the root injection layer. We can improve on that by finding the layer
that contains the given byte range and printing the subtree within that
layer. That gives more useful results when a selection is within an
injection layer.
mtoohey31 pushed a commit to mtoohey31/helix that referenced this pull request Jun 2, 2024
…r#9309)

`:tree-sitter-subtree` could previously only print subtrees of nodes
in the root injection layer. We can improve on that by finding the layer
that contains the given byte range and printing the subtree within that
layer. That gives more useful results when a selection is within an
injection layer.
Vulpesx pushed a commit to Vulpesx/helix that referenced this pull request Jun 7, 2024
…r#9309)

`:tree-sitter-subtree` could previously only print subtrees of nodes
in the root injection layer. We can improve on that by finding the layer
that contains the given byte range and printing the subtree within that
layer. That gives more useful results when a selection is within an
injection layer.
smortime pushed a commit to smortime/helix that referenced this pull request Jul 10, 2024
…r#9309)

`:tree-sitter-subtree` could previously only print subtrees of nodes
in the root injection layer. We can improve on that by finding the layer
that contains the given byte range and printing the subtree within that
layer. That gives more useful results when a selection is within an
injection layer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants