(doc, change, ignoreReadOnly)
| 5258 | // Apply a change to a document, and add it to the document's |
| 5259 | // history, and propagating it to all linked documents. |
| 5260 | function makeChange(doc, change, ignoreReadOnly) { |
| 5261 | if (doc.cm) { |
| 5262 | if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) } |
| 5263 | if (doc.cm.state.suppressEdits) { return } |
| 5264 | } |
| 5265 | |
| 5266 | if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) { |
| 5267 | change = filterChange(doc, change, true); |
| 5268 | if (!change) { return } |
| 5269 | } |
| 5270 | |
| 5271 | // Possibly split or suppress the update based on the presence |
| 5272 | // of read-only spans in its range. |
| 5273 | var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to); |
| 5274 | if (split) { |
| 5275 | for (var i = split.length - 1; i >= 0; --i) |
| 5276 | { makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}); } |
| 5277 | } else { |
| 5278 | makeChangeInner(doc, change); |
| 5279 | } |
| 5280 | } |
| 5281 | |
| 5282 | function makeChangeInner(doc, change) { |
| 5283 | if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) { return } |
no test coverage detected