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: Eli Zaretskii
Subject: Re: How to add pseudo vector types
Date: Tue, 03 Aug 2021 14:47:52 +0300

> From: Yuan Fu <casouri@gmail.com>
> Date: Fri, 30 Jul 2021 10:17:22 -0400
> Cc: Stephen Leake <stephen_leake@stephe-leake.org>,
>  Clément Pit-Claudel <cpitclaudel@gmail.com>,
>  Stefan Monnier <monnier@iro.umontreal.ca>,
>  emacs-devel@gnu.org
> 
> > That said, it looks like the code is correct: you should record the
> > changes in the entire buffer, but only pass to TS the changes inside
> > the restriction BEGV..ZV that is in effect at the time of the re-parse
> > call.  Btw, I don't see the code that filters changes reported to TS
> > by their positions against the restriction; did I miss something?
> 
> Yes, I do clip the change to the visible portion:
> 
> ts_record_change (ptrdiff_t start_byte, ptrdiff_t old_end_byte,
>                 ptrdiff_t new_end_byte)
> {
>   eassert(start_byte <= old_end_byte);
>   eassert(start_byte <= new_end_byte);
> 
>   Lisp_Object parser_list = Fsymbol_value (Qtree_sitter_parser_list);
> 
>   while (!NILP (parser_list))
>     {
>       Lisp_Object lisp_parser = Fcar (parser_list);
>       TSTree *tree = XTS_PARSER (lisp_parser)->tree;
>       if (tree != NULL)
>       {
>         /* We "clip" the change to between visible_beg and
>            visible_end.  It is okay if visible_end ends up larger
>            than BUF_Z, tree-sitter only access buffer text during
>            re-parse, and we will adjust visible_beg/end before
>            re-parse.  */
>         ptrdiff_t visible_beg = XTS_PARSER (lisp_parser)->visible_beg;
>         ptrdiff_t visible_end = XTS_PARSER (lisp_parser)->visible_end;
> 
>         ptrdiff_t visible_start =
>           max (visible_beg, start_byte) - visible_beg;
>         ptrdiff_t visible_old_end =
>           min (visible_end, old_end_byte) - visible_beg;
>         ptrdiff_t visible_new_end =
>           min (visible_end, new_end_byte) - visible_beg;
> 
>         ts_tree_edit_1 (tree, visible_start, visible_old_end,
>                         visible_new_end);
>         XTS_PARSER (lisp_parser)->need_reparse = true;
> 
>         parser_list = Fcdr (parser_list);

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?



reply via email to

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