[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to add pseudo vector types

From: Yuan Fu
Subject: Re: How to add pseudo vector types
Date: Thu, 29 Jul 2021 13:55:48 -0400

>> Ideally, tree-sitter only sees the narrowed region because everytime it is 
>> called, the buffer is narrowed. However, tree-sitter doesn’t work that way, 
>> it needs to be updated when user edits the buffer, when the buffer is 
>> widened. If your goal is give lisp control of what tree-sitter sees, we 
>> can’t just give tree-sitter the whole buffer whenever the user makes some 
>> change.
> In the above scenario, then the Lisp program that narrows the buffer
> should figure out how to do that correctly.  The call to TS will then
> express the changes in the narrowed region only.
>>> Anyway, you are once again bothered by a scenario that should not
>>> happen at all: a Lisp program should not call TS first with, then
>>> without narrowing (or the other way around).  I don't see why such
>>> situation should happen, and if they do, the Lisp programs which need
>>> them will have to figure out what to do and how.
>> Even if lisp always call tree-sitter with narrowing, we still need to update 
>> tree-sitter when the buffer is widened.
> No, I don't think so.  Why would we need to?  From the TS POV the text
> outside the restriction doesn't exist because it never sees it.

Actually, that sounds like how it works in my code right now. After the last 
few exchanges, I still have the feeling that we are not on the same page. Could 
you have a look at the code in ts_ensure_parsed and ts_record_change, and see 
if it aligns with what you consider to be the right thing? If you have read 
them already and think you understand what are they doing, could you tell me 
how exactly should these two functions behave, in your opinion? Thanks.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]