Skip to content

Commit 8780835

Browse files
authored
[soy mode] Fix bad matches of map, record, from, as, import
1 parent c194162 commit 8780835

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mode/soy/soy.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@
140140
state.context = new Context(state.context, "list-literal", state.variables);
141141
state.lookupVariables = false;
142142
return null;
143-
} else if (stream.match(/map\b/)) {
143+
} else if (stream.match(/\bmap(?=\()/)) {
144144
state.soyState.push("map-literal");
145145
return "keyword";
146-
} else if (stream.match(/record\b/)) {
146+
} else if (stream.match(/\brecord(?=\()/)) {
147147
state.soyState.push("record-literal");
148148
return "keyword";
149149
} else if (stream.match(/([\w]+)(?=\()/)) {
@@ -454,11 +454,11 @@
454454
state.indent -= 2 * config.indentUnit;
455455
return null;
456456
}
457-
if (stream.match(/\w+(?=\s+as)/)) {
457+
if (stream.match(/\w+(?=\s+as\b)/)) {
458458
return "variable";
459459
}
460460
if (match = stream.match(/\w+/)) {
461-
return /(from|as)/.test(match[0]) ? "keyword" : "def";
461+
return /\b(from|as)\b/.test(match[0]) ? "keyword" : "def";
462462
}
463463
if (match = stream.match(/^["']/)) {
464464
state.soyState.push("string");
@@ -605,7 +605,7 @@
605605
state.indent += 2 * config.indentUnit;
606606
state.soyState.push("tag");
607607
return "keyword";
608-
} else if (!state.context && stream.match(/\bimport\b/)) {
608+
} else if (!state.context && stream.sol() && stream.match(/import\b/)) {
609609
state.soyState.push("import");
610610
state.indent += 2 * config.indentUnit;
611611
return "keyword";

0 commit comments

Comments
 (0)