[ruby mode] Fix matching of closing brackets during indentation
Closes #5881
This commit is contained in:
parent
a86e85864c
commit
17f48fb56b
|
@ -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,7 +59,7 @@ 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();
|
||||
|
@ -280,9 +281,9 @@ CodeMirror.defineMode("ruby", function(config) {
|
|||
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);
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue