[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: Wed, 28 Jul 2021 12:36:33 -0400

> On Jul 27, 2021, at 11:40 PM, Stephen Leake <stephen_leake@stephe-leake.org> 
> wrote:
> Yuan Fu <casouri@gmail.com> writes:
>>>> We need to “delete” the hidden text and “re-insert” when we widen the
>>>> buffer. I’ll try to make it a no-op as long as we remember to widen
>>>> before calling tree-sitter to parse anything.
>>> First, the only thing TS deletes is tree nodes, not text; it does not
>>> have a copy of the buffer.
>>> Why do you think we need to delete the tree nodes corresponding to the
>>> hidden text? They provide exactly the context needed to parse the
>>> visible text properly.
>> I don’t think we need to, but I assume that tree-sitter will delete
>> the corresponding nodes if we hide the text from it. 
> No, tree-sitter only deletes nodes that cover changes.
> So don't send a change that deletes the hidden text; just send changes
> in the visible part of the text (that's the only place the user can make
> changes). tree-sitter will only run the scanner on the change regions,
> so it will only request text from the visible part of the buffer;
> all the requests will succeed.

Then we are not hiding the hidden text from tree-sitter. The implementation you 
described, IIUC, is essentially do nothing special when the buffer is narrowed. 

>> For us, the text is there, just hidden; for tree-sitter, the text is
>> deleted.
> No, it simply won't notice that it can't access that part of the buffer,
> because it will never try.
> What, exactly, will the buffer-text fetch code do if tree-sitter
> violates the narrowing (by some error in tree-sitter or user code)?
> throw an exception? return a null string?

In my current implementation, if tree-sitter access buffer content outside of 
narrowed region, it reads whitespaces, if it access buffer content outside of 
the buffer, it reads null string. Neither case throws an error.


reply via email to

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