GNOME Bugzilla – Bug 758024
Wrong syntax highlighting of new JS template strings
Last modified: 2016-01-31 14:17:21 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.
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
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.
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?
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
Thank you!