(doc, change, ignoreReadOnly)
| 4177 | // Apply a change to a document, and add it to the document's |
| 4178 | // history, and propagating it to all linked documents. |
| 4179 | function makeChange(doc, change, ignoreReadOnly) { |
| 4180 | if (doc.cm) { |
| 4181 | if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly); |
| 4182 | if (doc.cm.state.suppressEdits) return; |
| 4183 | } |
| 4184 | |
| 4185 | if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) { |
| 4186 | change = filterChange(doc, change, true); |
| 4187 | if (!change) return; |
| 4188 | } |
| 4189 | |
| 4190 | // Possibly split or suppress the update based on the presence |
| 4191 | // of read-only spans in its range. |
| 4192 | var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to); |
| 4193 | if (split) { |
| 4194 | for (var i = split.length - 1; i >= 0; --i) |
| 4195 | makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text}); |
| 4196 | } else { |
| 4197 | makeChangeInner(doc, change); |
| 4198 | } |
| 4199 | } |
| 4200 | |
| 4201 | function makeChangeInner(doc, change) { |
| 4202 | if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return; |
no test coverage detected