[go mode] Allow underscore separators in numbers

Closes https://github.com/codemirror/codemirror5/issues/7059
This commit is contained in:
Marijn Haverbeke 2023-09-01 08:56:11 +02:00
parent 854ee51ef2
commit 638abda97c
1 changed files with 3 additions and 3 deletions

View File

@ -46,11 +46,11 @@ CodeMirror.defineMode("go", function(config) {
}
if (/[\d\.]/.test(ch)) {
if (ch == ".") {
stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/);
stream.match(/^[0-9_]+([eE][\-+]?[0-9_]+)?/);
} else if (ch == "0") {
stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/);
stream.match(/^[xX][0-9a-fA-F_]+/) || stream.match(/^[0-7_]+/);
} else {
stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/);
stream.match(/^[0-9_]*\.?[0-9_]*([eE][\-+]?[0-9_]+)?/);
}
return "number";
}