()
| 82 | } |
| 83 | |
| 84 | function Import() { |
| 85 | _field.sendWithReturn("request.imports", { |
| 86 | box: cm.currentbox, |
| 87 | property: cm.currentproperty, |
| 88 | text: cm.getValue(), |
| 89 | line: cm.listSelections()[0].anchor.line, |
| 90 | ch: cm.listSelections()[0].anchor.ch |
| 91 | }, |
| 92 | function (d, e) { |
| 93 | var completions = d; |
| 94 | completionFunction = function (e) { |
| 95 | var m = []; |
| 96 | for (var i = 0; i < completions.length; i++) { |
| 97 | |
| 98 | if (completions[i].replaceWith.indexOf(e) > -1) { |
| 99 | pattern = new RegExp("(" + e + ")", "i"); |
| 100 | matched = completions[i].replaceWith.replace(pattern, "<span class='matched'>$1</span>"); |
| 101 | m.push({ |
| 102 | text: matched + " " + completions[i].info, |
| 103 | callback: function () { |
| 104 | cm.replaceRange(completions[this.i].replaceWith, cm.posFromIndex(completions[this.i].start), cm.posFromIndex(completions[this.i].end)); |
| 105 | cm.replaceRange(completions[this.i].header + "\n", { |
| 106 | line: 0, |
| 107 | ch: 0 |
| 108 | }); |
| 109 | |
| 110 | _field.sendWithReturn("execution.fragment", { |
| 111 | box: cm.currentbox, |
| 112 | property: cm.currentproperty, |
| 113 | text: completions[this.i].header, |
| 114 | disabledRanges: "[" + allDisabledBracketRanges() + "]" |
| 115 | }, function (d, e) { |
| 116 | if (d.tick) |
| 117 | clearOutputsOlderThan(0, cm.lineCount(), d.tick) |
| 118 | |
| 119 | if (d.type == 'error') |
| 120 | appendRemoteOutputToLine(anchorLine, d.line + " : " + d.message, "Field-remoteOutput", "Field-remoteOutput-error", 0); |
| 121 | else |
| 122 | appendRemoteOutputToLine(anchorLine, d.message, "Field-remoteOutput-error", "Field-remoteOutput", 1) |
| 123 | }); |
| 124 | |
| 125 | }.bind({ |
| 126 | "i": i |
| 127 | } |
| 128 | ), |
| 129 | ratio: matched.length / completions[i].replaceWith.length |
| 130 | |
| 131 | }) |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | // m.sort(function (a, b) { |
| 136 | // return (a.ratio==b.ratio) ? 0 : (a.ratio < b.ratio ? 1 : -1); |
| 137 | // }); |
| 138 | |
| 139 | return m |
| 140 | }; |
| 141 | if (completions.length > 0) |
no test coverage detected