After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 779236 - rust lifetimes are highlighted incorrectly
rust lifetimes are highlighted incorrectly
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
unspecified
Other All
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2017-02-26 01:23 UTC by Christopher VanZomeren
Modified: 2017-02-26 16:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
rust.lang: fix invalid-char context matching valid syntax (945 bytes, patch)
2017-02-26 01:31 UTC, Christopher VanZomeren
needs-work Details | Review
rust.lang: fix invalid-char context matching rust's lifetime syntax (1.47 KB, patch)
2017-02-26 16:15 UTC, Christopher VanZomeren
committed Details | Review

Description Christopher VanZomeren 2017-02-26 01:23:46 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.
Comment 1 Christopher VanZomeren 2017-02-26 01:31:55 UTC
Created attachment 346731 [details] [review]
rust.lang: fix invalid-char context matching valid syntax
Comment 2 Sébastien Wilmet 2017-02-26 08:27:58 UTC
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.
Comment 3 Christopher VanZomeren 2017-02-26 16:15:16 UTC
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.
Comment 4 Christopher VanZomeren 2017-02-26 16:16:43 UTC
I've updated the patch to explain what it does and why in the commit message.
Comment 5 Sébastien Wilmet 2017-02-26 16:53:08 UTC
Review of attachment 346762 [details] [review]:

OK, now I better understand. Looks good.
Comment 6 Sébastien Wilmet 2017-02-26 16:57:05 UTC
Attachment 346762 [details] pushed as 177a101 - rust.lang: fix invalid-char context matching rust's lifetime syntax