Packages: Rust code improperly highlighted

Created on 6 Apr 2020  路  3Comments  路  Source: sublimehq/Packages

Please see https://github.com/sharkdp/bat/issues/906 as this problem was discovered by another package using your highlighter.

  • Sublime Version:
  • OS Version: MacOS Catalina 10.15.4
mod state {
    pub struct State<const S: &'static str> {
        total: u32,
    }

    impl State<"init"> {
        pub fn new() -> Self {
            Self { total: 0 }
        }

        pub fn accumulate(self) -> State<"accumulate"> {
            State { total: self.total }
        }
    }

    impl State<"accumulate"> {
        pub fn add(&mut self, add: u32) {
            self.total += add
        }

        pub fn freeze(self) -> State<"freeze"> {
            State { total: self.total }
        }
    }
}

Observer - 2nd impl (and everything that follows it) not highlighted properly.

Screen Shot 2020-04-06 at 09 34 38

Most helpful comment

This is what it looks like with the mensioned PR.

grafik

I'd say there's still an issue with the closing > in State<...> but the overall look is a bit better.

All 3 comments

there is a PR open which may fix this: https://github.com/sublimehq/Packages/pull/2305
(unfortunately I'm not in a position to check atm)

unfortunately I'm not in a position to check atm

Since I'm using this package indirectly (bat uses it to highlight sources, and I install bat from its central repo), I'm not in a position to check it at all.

Hopefully, you'd be able to check it later?

Update

bat maintainer explained how I could try this. So, I cloned this repo, applied #2305 - and it worked as expected, fixing the problems I experienced syntax-highlighting Rust source code.

This is what it looks like with the mensioned PR.

grafik

I'd say there's still an issue with the closing > in State<...> but the overall look is a bit better.

Was this page helpful?
0 / 5 - 0 ratings