Skip to content

Commit

Permalink
[soy mode] Fix bad matches of map, record, from, as, import
Browse files Browse the repository at this point in the history
  • Loading branch information
axellew authored Nov 17, 2021
1 parent c194162 commit 8780835
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mode/soy/soy.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@
state.context = new Context(state.context, "list-literal", state.variables);
state.lookupVariables = false;
return null;
} else if (stream.match(/map\b/)) {
} else if (stream.match(/\bmap(?=\()/)) {
state.soyState.push("map-literal");
return "keyword";
} else if (stream.match(/record\b/)) {
} else if (stream.match(/\brecord(?=\()/)) {
state.soyState.push("record-literal");
return "keyword";
} else if (stream.match(/([\w]+)(?=\()/)) {
Expand Down Expand Up @@ -454,11 +454,11 @@
state.indent -= 2 * config.indentUnit;
return null;
}
if (stream.match(/\w+(?=\s+as)/)) {
if (stream.match(/\w+(?=\s+as\b)/)) {
return "variable";
}
if (match = stream.match(/\w+/)) {
return /(from|as)/.test(match[0]) ? "keyword" : "def";
return /\b(from|as)\b/.test(match[0]) ? "keyword" : "def";
}
if (match = stream.match(/^["']/)) {
state.soyState.push("string");
Expand Down Expand Up @@ -605,7 +605,7 @@
state.indent += 2 * config.indentUnit;
state.soyState.push("tag");
return "keyword";
} else if (!state.context && stream.match(/\bimport\b/)) {
} else if (!state.context && stream.sol() && stream.match(/import\b/)) {
state.soyState.push("import");
state.indent += 2 * config.indentUnit;
return "keyword";
Expand Down

0 comments on commit 8780835

Please sign in to comment.