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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some useful doc comments about node ids #3364

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

StratusFearMe21
Copy link

Hi! I'm currently using tree-sitter to power a plain-text presentation program I'm making, which has a Language Server integration. As a user is editing, I tried to associate slides with the Node IDs they corresponded to, that way I could easily update a slideshow preview on every keystroke

---------------- node id
{
    Title: ViewBox[0]^^..,
    Subtitle: ViewBox[1]__..,
}[]
----------------

---------------- node id
{
    Title: ViewBox[0]^^|,
    Subtitle: ViewBox[1]__|,
    NewText: Size[0]__..,
}[]
----------------

I found that this didn't work as expected, but it did work when I took the Node ID of a specific token within each slide, in my case, the first bracket

---------------- node id
{
----------------
    Title: ViewBox[0]^^..,
    Subtitle: ViewBox[1]__..,
}[]

---------------- node id
{
----------------
    Title: ViewBox[0]^^|,
    Subtitle: ViewBox[1]__|,
    NewText: Size[0]__..,
}[]

I was under the impression that if a Node was not marked as having changed, that it would always be reused. I found that this was not the case, and added some doc comments to the id() function under the Node struct. If there's anywhere else this information should go, I'll update this PR and put it there too. tree-sitter has been such an amazing tool to use, and integrate into everything I'm doing, and I can't thank y'all enough for making it 馃槃

@StratusFearMe21 StratusFearMe21 marked this pull request as draft May 15, 2024 22:24
@StratusFearMe21
Copy link
Author

StratusFearMe21 commented May 15, 2024

Sorry, old commits got in the PR, one sec Fixed

@StratusFearMe21 StratusFearMe21 marked this pull request as ready for review May 15, 2024 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant