GNU bug report logs - #75164
treesit-font-lock-fontify-region is easy to lost color on parse error. suggest to remain fontify on parse error.

Previous Next

Package: emacs;

Reported by: Eval Exec <execvy <at> gmail.com>

Date: Sat, 28 Dec 2024 16:26:01 UTC

Severity: minor

Tags: moreinfo

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eval Exec <execvy <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: treesit-font-lock-fontify-region is easy to lost color on parse
 error. suggest to remain fontify on parse error.
Date: Sun, 29 Dec 2024 00:25:24 +0800
Hello.
When I enable rust-ts-mode on a rust file, I found treesitter is easy
to make emacs buffer to lost color.
For example, on the following rust code:
```rust

struct Dog {
    name: String,
    age: u8,
}


struct ManyStruct {
    a: u8,
}

fn many_code(){
    fn fib(n: u32) -> u32 {
        if n == 0 {
            return 0;
        }
        if n == 1 {
            return 1;
        }
        fib(n - 1) + fib(n - 2)
    }
}

fn main() {
    // change below `//` to `/` to see the difference
    // {
}
```

the rust code is right, and the emacs buffer color is right on every
struct/functions.
But, if I change `// {` to `/ {`, then the rust code is wrong, this
buffer will lost all colors.
You can see the change on bellow images:

https://imgur.com/a/4Tnv0GJ

I suggest emacs can remain colors even if the code is wrong.

My emacs version info: GNU Emacs 31.0.50




This bug report was last modified 202 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.