MCPcopy
hub / github.com/nwutils/nw-sample-apps / loadFile

Function loadFile

mini-code-edit/cm/lib/codemirror.js:466–479  ·  view source on GitHub ↗
(file, i)

Source from the content-addressed store, hash-verified

464 if (!pos || options.readOnly) return;
465 if (files && files.length && window.FileReader && window.File) {
466 function loadFile(file, i) {
467 var reader = new FileReader;
468 reader.onload = function() {
469 text[i] = reader.result;
470 if (++read == n) {
471 pos = clipPos(pos);
472 operation(function() {
473 var end = replaceRange(text.join(""), pos, pos);
474 setSelectionUser(pos, end);
475 })();
476 }
477 };
478 reader.readAsText(file);
479 }
480 var n = files.length, text = Array(n), read = 0;
481 for (var i = 0; i < n; ++i) loadFile(files[i], i);
482 }

Callers 1

onDropFunction · 0.85

Calls 4

clipPosFunction · 0.85
operationFunction · 0.85
replaceRangeFunction · 0.85
setSelectionUserFunction · 0.85

Tested by

no test coverage detected