MCPcopy
hub / github.com/witheve/Eve / toEnclosingExpr

Function toEnclosingExpr

src/codemirror.js:9172–9190  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

9170 }
9171
9172 function toEnclosingExpr(cm) {
9173 var pos = cm.getCursor(), line = pos.line, ch = pos.ch;
9174 var stack = [];
9175 while (line >= cm.firstLine()) {
9176 var text = cm.getLine(line);
9177 for (var i = ch == null ? text.length : ch; i > 0;) {
9178 var ch = text.charAt(--i);
9179 if (ch == ")")
9180 stack.push("(");
9181 else if (ch == "]")
9182 stack.push("[");
9183 else if (ch == "}")
9184 stack.push("{");
9185 else if (/[\(\{\[]/.test(ch) && (!stack.length || stack.pop() != ch))
9186 return cm.extendSelection(Pos(line, i));
9187 }
9188 --line; ch = null;
9189 }
9190 }
9191
9192 function quit(cm) {
9193 cm.execCommand("clearSearch");

Callers

nothing calls this directly

Calls 5

getCursorMethod · 0.80
firstLineMethod · 0.80
getLineMethod · 0.80
extendSelectionMethod · 0.80
testMethod · 0.45

Tested by

no test coverage detected