MCPcopy
hub / github.com/HubSpot/messenger / readInput

Function readInput

docs/welcome/lib/executr/lib/CodeMirror/codemirror.js:1239–1262  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

1237 // events that indicate IME taking place, but these are not widely
1238 // supported or compatible enough yet to rely on.)
1239 function readInput(cm) {
1240 var input = cm.display.input, prevInput = cm.display.prevInput, view = cm.view, sel = view.sel;
1241 if (!view.focused || hasSelection(input) || isReadOnly(cm)) return false;
1242 var text = input.value;
1243 if (text == prevInput && posEq(sel.from, sel.to)) return false;
1244 startOperation(cm);
1245 view.sel.shift = false;
1246 var same = 0, l = Math.min(prevInput.length, text.length);
1247 while (same < l && prevInput[same] == text[same]) ++same;
1248 var from = sel.from, to = sel.to;
1249 if (same < prevInput.length)
1250 from = {line: from.line, ch: from.ch - (prevInput.length - same)};
1251 else if (view.overwrite && posEq(from, to) && !cm.display.pasteIncoming)
1252 to = {line: to.line, ch: Math.min(getLine(cm.view.doc, to.line).text.length, to.ch + (text.length - same))};
1253 var updateInput = cm.curOp.updateInput;
1254 updateDoc(cm, from, to, splitLines(text.slice(same)), "end",
1255 cm.display.pasteIncoming ? "paste" : "input", {from: from, to: to});
1256 cm.curOp.updateInput = updateInput;
1257 if (text.length > 1000) input.value = cm.display.prevInput = "";
1258 else cm.display.prevInput = text;
1259 endOperation(cm);
1260 cm.display.pasteIncoming = false;
1261 return true;
1262 }
1263
1264 function resetInput(cm, user) {
1265 var view = cm.view, minimal, selected;

Callers 3

slowPollFunction · 0.85
pFunction · 0.85
doHandleBindingFunction · 0.85

Calls 6

isReadOnlyFunction · 0.85
posEqFunction · 0.85
startOperationFunction · 0.85
getLineFunction · 0.85
updateDocFunction · 0.85
endOperationFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…