You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/pretokenise.js
+7-3Lines changed: 7 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -152,12 +152,16 @@
152
152
lettp="?";
153
153
if(tk.type.label=="`"){// template string
154
154
// acorn splits these up into tokens, so we have to work through to the end, then just include the full text
155
-
lettk2,hasTemplate=false;
155
+
lettk2,hasTemplate=false,nesting=0;
156
156
do{
157
157
tk2=t.getToken();
158
-
if(tk2.type.label=="${")
158
+
if(tk2.type.label=="${"){
159
159
hasTemplate=true;
160
-
}while(tk2.type.label!="`");
160
+
nesting++;
161
+
}
162
+
if(tk2.type.label=="{")nesting++;
163
+
if(tk2.type.label=="}")nesting--;
164
+
}while(nesting>0||tk2.type.label!="`");
161
165
tkEnd=tk2.end;
162
166
tkStr=code.substring(tk.start,tkEnd);
163
167
tp=hasTemplate ? "TEMPLATEDSTRING" : "STRING";// if we don't have any templates, treat as a normal string (https://github.com/espruino/Espruino/issues/2577)
0 commit comments