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

Function handleBackspace

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

Source from the content-addressed store, hash-verified

57 }
58
59 function handleBackspace(cm) {
60 var conf = getConfig(cm);
61 if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
62
63 var pairs = getOption(conf, "pairs");
64 var ranges = cm.listSelections();
65 for (var i = 0; i < ranges.length; i++) {
66 if (!ranges[i].empty()) return CodeMirror.Pass;
67 var around = charsAround(cm, ranges[i].head);
68 if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass;
69 }
70 for (var i = ranges.length - 1; i >= 0; i--) {
71 var cur = ranges[i].head;
72 cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete");
73 }
74 }
75
76 function handleEnter(cm) {
77 var conf = getConfig(cm);

Callers

nothing calls this directly

Calls 7

getConfigFunction · 0.85
charsAroundFunction · 0.85
emptyMethod · 0.80
indexOfMethod · 0.80
replaceRangeMethod · 0.80
getOptionFunction · 0.70
PosFunction · 0.50

Tested by

no test coverage detected