emacs-devel
[Top][All Lists]
Advanced

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

Re: How to add pseudo vector types


From: Stephen Leake
Subject: Re: How to add pseudo vector types
Date: Tue, 27 Jul 2021 20:40:56 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (windows-nt)

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.

> 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?

-- 
-- Stephe



reply via email to

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