Skip to content

Commit

Permalink
[r mode] Tweak regex for dots
Browse files Browse the repository at this point in the history
See https://stat.ethz.ch/R-manual/R-devel/library/base/html/dots.html and https://stat.ethz.ch/R-manual/R-devel/library/base/html/Reserved.html

Currently CodeMirror treats things like `..1.` and `...1` identically to `...`, `..1`, `..2`, etc.

The former two parse, but they parse as regular R objects per the naming rules seen e.g. here https://stat.ethz.ch/R-manual/R-devel/library/base/html/make.names.html

> 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. Names such as ".2way" are not valid, and neither are the reserved words.

Please LMK if this should be tested, with the caveat that this is my first ever contribution to JS code so some hand-holding would be nice
  • Loading branch information
MichaelChirico committed Apr 10, 2021
1 parent 7b9f8a6 commit 8abe468
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 @@ -54,7 +54,7 @@ CodeMirror.defineMode("r", function(config) {
} else if (ch == "`") {
stream.match(/[^`]+`/);
return "variable-3";
} else if (ch == "." && stream.match(/.[.\d]+/)) {
} else if (ch == "." && stream.match(/.(?:[.]|\d+)/)) {
return "keyword";
} else if (/[a-zA-Z\.]/.test(ch)) {
stream.eatWhile(/[\w\.]/);
Expand Down

0 comments on commit 8abe468

Please sign in to comment.