mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
codemirror updated to 5.47.0
This commit is contained in:
18
libraries/codemirror/mode/ruby/ruby.js
vendored
18
libraries/codemirror/mode/ruby/ruby.js
vendored
@@ -28,7 +28,8 @@ CodeMirror.defineMode("ruby", function(config) {
|
||||
var indentWords = wordObj(["def", "class", "case", "for", "while", "until", "module", "then",
|
||||
"catch", "loop", "proc", "begin"]);
|
||||
var dedentWords = wordObj(["end", "until"]);
|
||||
var matching = {"[": "]", "{": "}", "(": ")"};
|
||||
var opening = {"[": "]", "{": "}", "(": ")"};
|
||||
var closing = {"]": "[", "}": "{", ")": "("};
|
||||
var curPunc;
|
||||
|
||||
function chain(newtok, stream, state) {
|
||||
@@ -58,13 +59,13 @@ CodeMirror.defineMode("ruby", function(config) {
|
||||
else if (stream.eat(/[wxq]/)) { style = "string"; embed = false; }
|
||||
var delim = stream.eat(/[^\w\s=]/);
|
||||
if (!delim) return "operator";
|
||||
if (matching.propertyIsEnumerable(delim)) delim = matching[delim];
|
||||
if (opening.propertyIsEnumerable(delim)) delim = opening[delim];
|
||||
return chain(readQuoted(delim, style, embed, true), stream, state);
|
||||
} else if (ch == "#") {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
} else if (ch == "<" && (m = stream.match(/^<-?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) {
|
||||
return chain(readHereDoc(m[1]), stream, state);
|
||||
} else if (ch == "<" && (m = stream.match(/^<([-~])[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) {
|
||||
return chain(readHereDoc(m[2], m[1]), stream, state);
|
||||
} else if (ch == "0") {
|
||||
if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/);
|
||||
else if (stream.eat("b")) stream.eatWhile(/[01]/);
|
||||
@@ -216,8 +217,9 @@ CodeMirror.defineMode("ruby", function(config) {
|
||||
return style;
|
||||
};
|
||||
}
|
||||
function readHereDoc(phrase) {
|
||||
function readHereDoc(phrase, mayIndent) {
|
||||
return function(stream, state) {
|
||||
if (mayIndent) stream.eatSpace()
|
||||
if (stream.match(phrase)) state.tokenize.pop();
|
||||
else stream.skipToEnd();
|
||||
return "string";
|
||||
@@ -276,12 +278,12 @@ CodeMirror.defineMode("ruby", function(config) {
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize[state.tokenize.length-1] != tokenBase) return 0;
|
||||
if (state.tokenize[state.tokenize.length-1] != tokenBase) return CodeMirror.Pass;
|
||||
var firstChar = textAfter && textAfter.charAt(0);
|
||||
var ct = state.context;
|
||||
var closing = ct.type == matching[firstChar] ||
|
||||
var closed = ct.type == closing[firstChar] ||
|
||||
ct.type == "keyword" && /^(?:end|until|else|elsif|when|rescue)\b/.test(textAfter);
|
||||
return ct.indented + (closing ? 0 : config.indentUnit) +
|
||||
return ct.indented + (closed ? 0 : config.indentUnit) +
|
||||
(state.continuedLine ? config.indentUnit : 0);
|
||||
},
|
||||
|
||||
|
||||
7
libraries/codemirror/mode/ruby/test.js
vendored
7
libraries/codemirror/mode/ruby/test.js
vendored
@@ -13,4 +13,11 @@
|
||||
|
||||
MT("complex_regexp",
|
||||
"[keyword if] [variable cr] [operator =~] [string-2 /(?: \\( #{][tag RE_NOT][string-2 }\\( | #{][tag RE_NOT_PAR_OR][string-2 }* #{][tag RE_OPA_OR][string-2 } )/][variable x]")
|
||||
|
||||
MT("indented_heredoc",
|
||||
"[keyword def] [def x]",
|
||||
" [variable y] [operator =] [string <<-FOO]",
|
||||
"[string bar]",
|
||||
"[string FOO]",
|
||||
"[keyword end]")
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user