Skip to content

Commit 8abe468

Browse files
[r mode] Tweak regex for dots
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
1 parent 7b9f8a6 commit 8abe468

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mode/r/r.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ CodeMirror.defineMode("r", function(config) {
5454
} else if (ch == "`") {
5555
stream.match(/[^`]+`/);
5656
return "variable-3";
57-
} else if (ch == "." && stream.match(/.[.\d]+/)) {
57+
} else if (ch == "." && stream.match(/.(?:[.]|\d+)/)) {
5858
return "keyword";
5959
} else if (/[a-zA-Z\.]/.test(ch)) {
6060
stream.eatWhile(/[\w\.]/);

0 commit comments

Comments
 (0)