QOwnNotes icon indicating copy to clipboard operation
QOwnNotes copied to clipboard

Rust code highlighting - character highlighting incorrectly used for lifetime identifiers.

Open Gremious opened this issue 5 years ago • 2 comments

I know highlighting is always in the works, just wanted to leave this issue to help with tracking.

In Rust, 'a' is a a character. 'a is a lifetime identifier. This isn't limited to 'a, but can be any number of letters, including:

'b
'bar, 'baz
'static

Expected behaviour

Correct highlighting:

struct Foo<'a> {
    a: 'a char, // variable with name "a" will be of type character with a lifetime of 'a
}

fn main() {
    let f = Foo { a: 'a' }; // "variable a = the char 'a'"
}

Actual behaviour

Everything between a pair of "''s" is highlighted (sorta:).

Steps to reproduce

Write

impl<'a> Foo<'a> for Bar {
    type Baz = (
        a<'a, x>,
        b<'a, y>,
        c<'a, z>,
    );

surrounded with a rust block quote. In the preview window, everything between two "''s" is highlighted no matter how far away the next one is (which potentially just makes your near-entire codeblock highlighted in 1 color). In the writing window, everything between two "''s" or a a "''" and a linebreak is highlighted, whichever comes first.

Gremious avatar Jun 20 '20 11:06 Gremious

@Waqar144? :grin:

pbek avatar Jun 20 '20 12:06 pbek

In Rust, 'a' is a a character.

Indeed.

This isn't really difficult to implement, but I don't want every language to go through this check.

Waqar144 avatar Jun 22 '20 08:06 Waqar144