MCPcopy Index your code
hub / github.com/DHTMLX/gantt / triggerElectric

Function triggerElectric

samples/common/codehighlight/codemirror.js:8162–8184  ·  view source on GitHub ↗
(cm, inserted)

Source from the content-addressed store, hash-verified

8160 }
8161
8162 function triggerElectric(cm, inserted) {
8163 // When an 'electric' character is inserted, immediately trigger a reindent
8164 if (!cm.options.electricChars || !cm.options.smartIndent) { return }
8165 var sel = cm.doc.sel;
8166
8167 for (var i = sel.ranges.length - 1; i >= 0; i--) {
8168 var range = sel.ranges[i];
8169 if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) { continue }
8170 var mode = cm.getModeAt(range.head);
8171 var indented = false;
8172 if (mode.electricChars) {
8173 for (var j = 0; j < mode.electricChars.length; j++)
8174 { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
8175 indented = indentLine(cm, range.head.line, "smart");
8176 break
8177 } }
8178 } else if (mode.electricInput) {
8179 if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
8180 { indented = indentLine(cm, range.head.line, "smart"); }
8181 }
8182 if (indented) { signalLater(cm, "electricInput", cm, range.head.line); }
8183 }
8184 }
8185
8186 function copyableRanges(cm) {
8187 var text = [], ranges = [];

Callers 2

applyTextInputFunction · 0.85
addEditorMethodsFunction · 0.85

Calls 3

indentLineFunction · 0.85
getLineFunction · 0.85
signalLaterFunction · 0.85

Tested by

no test coverage detected