(file, i)
| 2758 | if (files && files.length && window.FileReader && window.File) { |
| 2759 | var n = files.length, text = Array(n), read = 0; |
| 2760 | var loadFile = function(file, i) { |
| 2761 | var reader = new FileReader; |
| 2762 | reader.onload = operation(cm, function() { |
| 2763 | text[i] = reader.result; |
| 2764 | if (++read == n) { |
| 2765 | pos = clipPos(cm.doc, pos); |
| 2766 | var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"}; |
| 2767 | makeChange(cm.doc, change); |
| 2768 | setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))); |
| 2769 | } |
| 2770 | }); |
| 2771 | reader.readAsText(file); |
| 2772 | }; |
| 2773 | for (var i = 0; i < n; ++i) loadFile(files[i], i); |
| 2774 | } else { // Normal drop |
| 2775 | // Don't do a replace if the drop happened inside of the selected text. |
no test coverage detected