emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree sitter support for C-like languages


From: Yuan Fu
Subject: Re: Tree sitter support for C-like languages
Date: Sun, 13 Nov 2022 16:22:36 -0800


> On Nov 13, 2022, at 1:56 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Theodor Thornhill <theo@thornhill.no>
>> Cc: casouri@gmail.com, emacs-devel@gnu.org, monnier@iro.umontreal.ca
>> Date: Sun, 13 Nov 2022 10:40:26 +0100
>> 
>>> But if I add an empty line at BOB, the fontification becomes as
>>> expected, and doesn't go back to font-lock-warning-face even if I then
>>> remove that empty line.
>>> 
>> 
>> This is likely due to either treesit or tree-sitter or tree-sitter-c not
>> dealing properly with the root node.  Maybe Yuan has some insight here?
> 
> This sounds like we don't update tree-sitter under some conditions,
> IOW a bug of sorts.

That’s just due to jit-lock. When jit-lock first fontifies

int
foo (void)
{

The parse tree has errors and it fontifies int in warning face.

Then when you insert the closing bracket, the parse tree is complete

int
foo (void)
{
 int bar = 0;
}

Int is still in warning face because jit-lock doesn’t know it needs to be 
refontified. When you insert a newline in BOB, jit-lock refortifies everything 
after the changed region, so int is refontified. 

So if we want the warning face to automatically disappear, we need to record 
these warning faces and remember to come back to refontify them later. We need 
to know when to refontify them, and know when to stop trying to refontify them 
(maybe the error isn’t transient). For now I think it’s best to just not 
fontify the error nodes. 

Yuan


reply via email to

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