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 758024 - Wrong syntax highlighting of new JS template strings
Wrong syntax highlighting of new JS template strings
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2015-11-12 18:52 UTC by Sander
Modified: 2016-01-31 14:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add highlighting for Template-Strings (3.15 KB, patch)
2016-01-31 09:23 UTC, Tobias Schönberg
none Details | Review
Screenshot showing some problems with the highlighting (22.15 KB, image/png)
2016-01-31 09:29 UTC, Tobias Schönberg
  Details
Add highlighting for ES6 Template Strings (2.49 KB, patch)
2016-01-31 14:03 UTC, Tobias Schönberg
none Details | Review

Description Sander 2015-11-12 18:52:53 UTC
Recently, ES6 was standardised, and this added support for template strings in JS: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings

Basically these are multi-line strings, but they also include variables.

However, initial support as a multi-line string (like in python) might already be good enough. Currently the content of these template strings influences the rest of the syntax highlighting, making the file unreadable in some cases.
Comment 1 Tobias Schönberg 2016-01-31 09:23:15 UTC
Created attachment 320105 [details] [review]
Add highlighting for Template-Strings

Template strings are part of ES6 and are currently not
highlighted as strings. This patch adds a context that
gives template strings the same color as single-quoted
and double-quoted strings. The brackets of the template
expressions are given the color of functions. The
inside of the expressions need some additional work,
because the color of the string continues inside of
the template expression.

https://bugzilla.gnome.org/show_bug.cgi?id=758024
Fixes #758024
Comment 2 Tobias Schönberg 2016-01-31 09:29:48 UTC
Created attachment 320106 [details]
Screenshot showing some problems with the highlighting

Both Oblivion and Builder-Dark Theme show that some formatting continues within the template expression brackets. It would be better to reset to the default colors within these expressions.
Comment 3 Paolo Borelli 2016-01-31 10:33:05 UTC
Review of attachment 320105 [details] [review]:

Thanks for the patch. Maybe for now we can keep the expressions inside the template simpler? I know they can contain all that other kind of contexts, but I fear that doing full highlighting inside the expression may be more confusing: when reading code I think the primary thing we should communicate is "you are inside an expression in a template string", if we start doing a lot of fancy highlighting I think it may get confused with the case where the template is finished and we are back in the "normal code" context.

I was thinking of doing something along the lines of c:printf or python:format. What do you think?
Comment 4 Tobias Schönberg 2016-01-31 14:03:52 UTC
Created attachment 320123 [details] [review]
Add highlighting for ES6 Template Strings

Template strings are part of ES6 and are currently not
highlighted as strings. This patch adds a context that
gives template strings the same color as single-quoted
and double-quoted strings. The brackets of the template
expressions are given the color of functions. The
expressions themselves are highlighted as functions
too.

https://bugzilla.gnome.org/show_bug.cgi?id=758024
Fixes #758024
Comment 5 Paolo Borelli 2016-01-31 14:17:21 UTC
Thank you!