Skip to content

Commit

Permalink
[r mode] Remove extra test with more appropriate regexp
Browse files Browse the repository at this point in the history
The rule for starting a variable name is:

> A syntactically valid name consists of letters, numbers and the dot or underline characters and **starts with a letter or the dot not followed by a number**.

Per https://stat.ethz.ch/R-manual/R-devel/library/base/html/make.names.html

"dot not followed by a number" is handled by parsing numerics earlier
  • Loading branch information
MichaelChirico committed Apr 10, 2021
1 parent 8fed31e commit 7b9f8a6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mode/r/r.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ CodeMirror.defineMode("r", function(config) {
return "variable-3";
} else if (ch == "." && stream.match(/.[.\d]+/)) {
return "keyword";
} else if (/[\w\.]/.test(ch) && ch != "_") {
} else if (/[a-zA-Z\.]/.test(ch)) {
stream.eatWhile(/[\w\.]/);
var word = stream.current();
if (atoms.propertyIsEnumerable(word)) return "atom";
Expand Down

0 comments on commit 7b9f8a6

Please sign in to comment.