GNOME Bugzilla – Bug 779236
rust lifetimes are highlighted incorrectly
Last modified: 2017-02-26 16:57:09 UTC
Lifetimes in rust use a single quote as part of their syntax. This is misidentified as part of an invalid character by the syntax highlighting in GTKSourceView if another single quote is found somewhere on the line. Example: struct SomeObject<'a, T: 'a> {} Everything between the quotes on this line is highlighted as invalid-char. This can be fixed by making the invalid-char context not match if the second quote is followed by an identifier.
Created attachment 346731 [details] [review] rust.lang: fix invalid-char context matching valid syntax
Review of attachment 346731 [details] [review]: By just looking at the patch, I don't know what it does. Please describe the change in the commit message, with the Rust example that you've given.
Created attachment 346762 [details] [review] rust.lang: fix invalid-char context matching rust's lifetime syntax Lifetimes in rust use a single quote as part of their syntax. When 2 or more lifetimes appear on a line, part of the line is (incorrectly) highlighted by the invalid-char context. Example: struct SomeObject<'a, T: 'a> {} Before this patch, everything between the quotes on this line is highlighted as invalid-char. This patch prevents the invalid-char context in rust.lang from matching single quotes which are part of the lifetime syntax, by abandoning a match for invalid-char if the closing quote is immediately followed by an identifier.
I've updated the patch to explain what it does and why in the commit message.
Review of attachment 346762 [details] [review]: OK, now I better understand. Looks good.
Attachment 346762 [details] pushed as 177a101 - rust.lang: fix invalid-char context matching rust's lifetime syntax