mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 10:55:55 +01:00
codemirro 5.48.4
This commit is contained in:
@@ -67,7 +67,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
if (ch == '"' || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
} else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
|
||||
} else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) {
|
||||
return ret("number", "number");
|
||||
} else if (ch == "." && stream.match("..")) {
|
||||
return ret("spread", "meta");
|
||||
@@ -75,10 +75,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
return ret(ch);
|
||||
} else if (ch == "=" && stream.eat(">")) {
|
||||
return ret("=>", "operator");
|
||||
} else if (ch == "0" && stream.match(/^(?:x[\da-f]+|o[0-7]+|b[01]+)n?/i)) {
|
||||
} else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) {
|
||||
return ret("number", "number");
|
||||
} else if (/\d/.test(ch)) {
|
||||
stream.match(/^\d*(?:n|(?:\.\d*)?(?:[eE][+\-]?\d+)?)?/);
|
||||
stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/);
|
||||
return ret("number", "number");
|
||||
} else if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
@@ -195,8 +195,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
++depth;
|
||||
} else if (wordRE.test(ch)) {
|
||||
sawSomething = true;
|
||||
} else if (/["'\/]/.test(ch)) {
|
||||
return;
|
||||
} else if (/["'\/`]/.test(ch)) {
|
||||
for (;; --pos) {
|
||||
if (pos == 0) return
|
||||
var next = stream.string.charAt(pos - 1)
|
||||
if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break }
|
||||
}
|
||||
} else if (sawSomething && !depth) {
|
||||
++pos;
|
||||
break;
|
||||
@@ -574,10 +578,13 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
}
|
||||
function maybetype(type, value) {
|
||||
if (isTS) {
|
||||
if (type == ":" || value == "in") return cont(typeexpr);
|
||||
if (type == ":") return cont(typeexpr);
|
||||
if (value == "?") return cont(maybetype);
|
||||
}
|
||||
}
|
||||
function maybetypeOrIn(type, value) {
|
||||
if (isTS && (type == ":" || value == "in")) return cont(typeexpr)
|
||||
}
|
||||
function mayberettype(type) {
|
||||
if (isTS && type == ":") {
|
||||
if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
|
||||
@@ -618,7 +625,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
} else if (type == ":") {
|
||||
return cont(typeexpr)
|
||||
} else if (type == "[") {
|
||||
return cont(expect("variable"), maybetype, expect("]"), typeprop)
|
||||
return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop)
|
||||
} else if (type == "(") {
|
||||
return pass(functiondecl, typeprop)
|
||||
}
|
||||
|
||||
19
libraries/codemirror/mode/javascript/test.js
vendored
19
libraries/codemirror/mode/javascript/test.js
vendored
@@ -127,6 +127,9 @@
|
||||
"[keyword let] [def f] [operator =] ([[ [def a], [def b] ]], [def c]) [operator =>] [variable-2 a] [operator +] [variable-2 c];",
|
||||
"[variable c];");
|
||||
|
||||
MT("fatArrow_stringDefault",
|
||||
"([def a], [def b] [operator =] [string 'x\\'y']) [operator =>] [variable-2 a] [operator +] [variable-2 b]")
|
||||
|
||||
MT("spread",
|
||||
"[keyword function] [def f]([def a], [meta ...][def b]) {",
|
||||
" [variable something]([variable-2 a], [meta ...][variable-2 b]);",
|
||||
@@ -298,6 +301,22 @@
|
||||
"[keyword return]",
|
||||
"{} [string-2 /5/]")
|
||||
|
||||
MT("numeric separator",
|
||||
"[number 123_456];",
|
||||
"[number 0xdead_c0de];",
|
||||
"[number 0o123_456];",
|
||||
"[number 0b1101_1101];",
|
||||
"[number .123_456e0_1];",
|
||||
"[number 1E+123_456];",
|
||||
"[number 12_34_56n];")
|
||||
|
||||
MT("underscore property",
|
||||
"[variable something].[property _property];",
|
||||
"[variable something].[property _123];",
|
||||
"[variable something].[property _for];",
|
||||
"[variable _for];",
|
||||
"[variable _123];")
|
||||
|
||||
var ts_mode = CodeMirror.getMode({indentUnit: 2}, "application/typescript")
|
||||
function TS(name) {
|
||||
test.mode(name, ts_mode, Array.prototype.slice.call(arguments, 1))
|
||||
|
||||
Reference in New Issue
Block a user