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 775918 - Rust syntax highlighting doesn't recognise nested block comments
Rust syntax highlighting doesn't recognise nested block comments
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
3.22.x
Other Linux
: Normal minor
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2016-12-10 05:03 UTC by Shreepad S
Modified: 2017-02-04 19:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot of incorrect Rust block comment highlighting (28.82 KB, image/png)
2016-12-10 05:03 UTC, Shreepad S
  Details
rust.lang: Fix highlighting of nested multiline comments (1.43 KB, patch)
2017-01-01 18:55 UTC, Tobias Schönberg
committed Details | Review
Screenshot of corrected Rust block comment highlighting (27.50 KB, image/png)
2017-02-04 18:56 UTC, Shreepad S
  Details

Description Shreepad S 2016-12-10 05:03:36 UTC
Created attachment 341708 [details]
Screenshot of incorrect Rust block comment highlighting

In the following code fragment, syntax highlighting doesn't recognise the indented block comment that is allowed in Rust. The 10th and 11th lines should be highlighted as comments but are not.

Screenshot attached. Running on Fedora 25 (64 bit Workstation build).


// Rust Block comments with nesting

fn main() {

    /* Start block comment
       Here we go
       /* 
         Nested 
       */
       Out
    */
    
    let x = 5 + /* 90  + */ 5;
    println!("Is `x` 10 or 100? x = {}", x);
}
Comment 1 Tobias Schönberg 2017-01-01 18:55:55 UTC
Created attachment 342698 [details] [review]
rust.lang: Fix highlighting of nested multiline comments

Currently the highlighting of nested multiline comments is
escaped at the first closing tag.
This commit adds a context that allows for nested multiline
comments.
Comment 2 Sébastien Wilmet 2017-01-02 10:31:01 UTC
Review of attachment 342698 [details] [review]:

Thanks, looks good.
Comment 3 Sébastien Wilmet 2017-01-15 12:09:22 UTC
Attachment 342698 [details] pushed as c8b4218 - rust.lang: Fix highlighting of nested multiline comments
Comment 4 Shreepad S 2017-02-04 13:36:14 UTC
Tobias, Sebastien, thanks for the patch!

To test the patch can I drop the new language-specs/rust.lang file somewhere in my home directory or do I need to put it in the system directories somewhere?

Shreepad
Comment 5 Tobias Schönberg 2017-02-04 18:35:24 UTC
You should have a folder at ~/.local/share/gtksourceview/lang-specs or similar where you can put the file. Files in that folder will have priority over the installed ones.
Comment 6 Shreepad S 2017-02-04 18:55:28 UTC
Thanks Tobias!

I created the folder ~/.local/share/gtksourceview-3.0/language-specs to match the structure in /usr/share and dropped the new rust.lang file there.

Is working fine now as per attached screenshot!
Comment 7 Shreepad S 2017-02-04 18:56:29 UTC
Created attachment 344944 [details]
Screenshot of corrected Rust block comment highlighting
Comment 8 Sébastien Wilmet 2017-02-04 19:01:32 UTC
For the record, the documentation is here:
https://developer.gnome.org/gtksourceview/stable/lang-reference.html

(it's mixed with the "developer" documentation, maybe we should create a separate user documentation)