A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg00860.html below:

Re: Tree sitter support for C-like languages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] 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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4