MCPcopy Create free account
hub / github.com/breck7/scroll / loadFile

Function loadFile

external/.scrollLibs.js:8806–8826  ·  view source on GitHub ↗
(file, i)

Source from the content-addressed store, hash-verified

8804 text = Array(n),
8805 read = 0
8806 var loadFile = function (file, i) {
8807 if (cm.options.allowDropFileTypes && indexOf(cm.options.allowDropFileTypes, file.type) == -1) {
8808 return
8809 }
8810
8811 var reader = new FileReader()
8812 reader.onload = operation(cm, function () {
8813 var content = reader.result
8814 if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) {
8815 content = ""
8816 }
8817 text[i] = content
8818 if (++read == n) {
8819 pos = clipPos(cm.doc, pos)
8820 var change = { from: pos, to: pos, text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())), origin: "paste" }
8821 makeChange(cm.doc, change)
8822 setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)))
8823 }
8824 })
8825 reader.readAsText(file)
8826 }
8827 for (var i = 0; i < n; ++i) {
8828 loadFile(files[i], i)
8829 }

Callers 1

onDropFunction · 0.85

Calls 8

indexOfFunction · 0.85
operationFunction · 0.85
clipPosFunction · 0.85
makeChangeFunction · 0.85
simpleSelectionFunction · 0.85
changeEndFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected