MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / handleEnter

Function handleEnter

lib/web/CodeMirror/addon/edit/closebrackets.js:76–98  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

74 }
75
76 function handleEnter(cm) {
77 var conf = getConfig(cm);
78 var explode = conf && getOption(conf, "explode");
79 if (!explode || cm.getOption("disableInput")) return CodeMirror.Pass;
80
81 var ranges = cm.listSelections();
82 for (var i = 0; i < ranges.length; i++) {
83 if (!ranges[i].empty()) return CodeMirror.Pass;
84 var around = charsAround(cm, ranges[i].head);
85 if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass;
86 }
87 cm.operation(function() {
88 var linesep = cm.lineSeparator() || "\n";
89 cm.replaceSelection(linesep + linesep, null);
90 moveSel(cm, -1)
91 ranges = cm.listSelections();
92 for (var i = 0; i < ranges.length; i++) {
93 var line = ranges[i].head.line;
94 cm.indentLine(line, null, true);
95 cm.indentLine(line + 1, null, true);
96 }
97 });
98 }
99
100 function moveSel(cm, dir) {
101 var newRanges = [], ranges = cm.listSelections(), primary = 0

Callers

nothing calls this directly

Calls 6

getConfigFunction · 0.85
charsAroundFunction · 0.85
moveSelFunction · 0.85
emptyMethod · 0.80
indexOfMethod · 0.80
getOptionFunction · 0.70

Tested by

no test coverage detected