[Top][All Lists]

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

Re: [SPAM UNSURE] Re: Initial fontification in sh-mode with tree-sittter

From: Stephen Leake
Subject: Re: [SPAM UNSURE] Re: Initial fontification in sh-mode with tree-sittter
Date: Wed, 02 Nov 2022 13:37:55 -0700
User-agent: Gnus/5.13 (Gnus v5.13)

Yuan Fu <casouri@gmail.com> writes:

> I think I’ve fixed this problem. It is mainly due to how the
> fortifications rule is written. When the starting quotes are inserted,
> normal syntactic font-lock will mark everything behind it in
> string-face, but for tree-sitter, since the source is incomplete, the
> quotes are in an error node in the parse tree and there is no string
> node, so tree-sitter rules can’t capture any string node, so no string
> face is applied. And when the ending quotes are inserted, the only
> region jit-lock wants tree-sitter to fontify is that three quote, so
> again the whole string is not captured. 

I'd say this is a bug in tree-sitter itself (probably in edit-tree). I'm
still fixing similar bugs in the wisi incremental parser.

> I changed the font-lock rule to match the ending quote rather than the
> whole string, and now it’s working fine.

A reasonable workaround, but perhaps submit a bug report to tree-sitter

> Now it is actually better than before: If you insert an open quote,
> the rest of the buffer will not be marked in string face, instead, and
> when you insert the ending quote, the string is fontified correctly.

People's notion of "better" will differ here. I'd say it is at best

Best would be to highlight that initial single quote in some
error face (bright red). The user could be intending that as the end
quote, so declaring everything after it to be a string is just wrong.

-- Stephe

reply via email to

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