bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#59574: 29.0.50; Emacs crashes when using tree-sitter-based mode in a


From: Eli Zaretskii
Subject: bug#59574: 29.0.50; Emacs crashes when using tree-sitter-based mode in an empty buffer
Date: Sat, 26 Nov 2022 16:31:59 +0200

> From: Yuan Fu <casouri@gmail.com>
> Date: Fri, 25 Nov 2022 19:18:09 -0800
> Cc: 59574@debbugs.gnu.org
> 
> > There's also something strange in treesit_record_change: when it is called
> > for the first time in a buffer which was empty and you insert one character,
> > we bypass the updating of visible_beg and visible_end fields of the Lisp
> > parser object, because XTS_PARSER (lisp_parser)->tree is NULL.  But it looks
> > to me that we should still update these two fields regardless, no?  Only the
> > call to treesit_tree_edit_1 needs the tree.  (I thought that maybe this lack
> > of update explains the assertion, but even if I move the condition to guard
> > only treesit_tree_edit_1, the assertion still happens, so I guess my
> > hypothesis eats dust.)
> 
> We don’t need to update visible_beg/end in treesit_record_change if tree is 
> NULL, because visible_beg/end represents the range of buffer that the tree 
> sees, so if there is no tree, visible_beg/end can be considered 
> uninitialized. However you are right about needing to update visible_beg/end, 
> but in treesit_ensure_position_synced (I renamed it to 
> treesit_sync_visible_region): that’s where we ensure visible_beg/end equals 
> to BUF_BEGV_BYTE/friends. 
> 
> The problem is we don’t update visible_beg/end for the very first parse, when 
> tree is NULL.
> 
> I also added some comments, hopefully they sufficiently explain everything.

Thanks, the problem is gone, so I'm closing the bug.





reply via email to

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