[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to add pseudo vector types
From: |
Fu Yuan |
Subject: |
Re: How to add pseudo vector types |
Date: |
Tue, 3 Aug 2021 09:00:46 -0400 |
> 在 2021年8月3日,上午8:25,Eli Zaretskii <eliz@gnu.org> 写道:
>
>
>>
>> From: Fu Yuan <casouri@gmail.com>
>> Date: Tue, 3 Aug 2021 08:00:46 -0400
>> Cc: stephen_leake@stephe-leake.org, cpitclaudel@gmail.com,
>> monnier@iro.umontreal.ca, emacs-devel@gnu.org
>>
>>> Hmm... so a change that begins before the restriction and ends inside
>>> the restriction will be sent as if it began at BEGV? And the rest of
>>> the change will be discarded? Shouldn't you split such changes in
>>> tow, send to TS the part inside the restriction, and store the rest
>>> for the future, when/if the buffer is widened?
>>
>> Tree-sitter doesn’t care about the content in a change, it will re-scan the
>> buffer content when it re-parses. We only need to inform it the range of the
>> change, so it knows where to re-scan when it re-parses. When the buffer is
>> widened, we will tell tree-sitter that range [BUF_BEG, BUF_BEGV] has
>> changed, and it will re-scan that part when re-parsing.
>
> But that's sub-optimal, no? Imagine a very large buffer which was
> narrowed to a small portion near EOB, then a modification made very
> close to EOB but partially before BEGV, then the buffer widened. With
> your method, TS will now have to re-parse almost the entire buffer,
> whereas we know it needs to re-parse a very small portion of it.
It is indeed, but that’s unavoidable by the way we hide the hidden part of the
buffer from tree-sitter. We pretend BUF_BEGV is the beginning of the buffer and
nothing exists before it. Then when we widen, we need to “insert” the content
between BUF_BEG and BUF_BEGV. I.e., as far as tree-sitter can tell, we inserted
that text.
If you want to hide something then re-show it to tree-sitter, and want
tree-sitter to know how to re-parse minimally, you should use
tree-sitter-parser-set-included-ranges (ts_parser_set_included_ranges). I’ve
wrote the lisp binding for it but haven’t pushed the change.
The reason why I didn’t implement narrow with set-ranges was explained earlier.
Yuan
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/08/03
- Re: How to add pseudo vector types, Fu Yuan, 2021/08/03
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/08/03
- Re: How to add pseudo vector types,
Fu Yuan <=
- Re: How to add pseudo vector types, Stefan Monnier, 2021/08/03
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/08/03
- Re: How to add pseudo vector types, Yuan Fu, 2021/08/05
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/08/06
- Tree-sitter api (Was: Re: How to add pseudo vector types), Fu Yuan, 2021/08/07
- Re: Tree-sitter api (Was: Re: How to add pseudo vector types), Eli Zaretskii, 2021/08/07
- Re: Tree-sitter api, Stefan Monnier, 2021/08/07
- Re: Tree-sitter api, Theodor Thornhill, 2021/08/07
- Re: Tree-sitter api, Stefan Monnier, 2021/08/07
- Re: Tree-sitter api, Yuan Fu, 2021/08/17