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

Function makeChange

external/.scrollLibs.js:7139–7166  ·  view source on GitHub ↗
(doc, change, ignoreReadOnly)

Source from the content-addressed store, hash-verified

7137 // Apply a change to a document, and add it to the document's
7138 // history, and propagating it to all linked documents.
7139 function makeChange(doc, change, ignoreReadOnly) {
7140 if (doc.cm) {
7141 if (!doc.cm.curOp) {
7142 return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly)
7143 }
7144 if (doc.cm.state.suppressEdits) {
7145 return
7146 }
7147 }
7148
7149 if (hasHandler(doc, "beforeChange") || (doc.cm && hasHandler(doc.cm, "beforeChange"))) {
7150 change = filterChange(doc, change, true)
7151 if (!change) {
7152 return
7153 }
7154 }
7155
7156 // Possibly split or suppress the update based on the presence
7157 // of read-only spans in its range.
7158 var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to)
7159 if (split) {
7160 for (var i = split.length - 1; i >= 0; --i) {
7161 makeChangeInner(doc, { from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin })
7162 }
7163 } else {
7164 makeChangeInner(doc, change)
7165 }
7166 }
7167
7168 function makeChangeInner(doc, change) {
7169 if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) {

Callers 4

replaceRangeFunction · 0.85
.scrollLibs.jsFile · 0.85
loadFileFunction · 0.85
applyTextInputFunction · 0.85

Calls 5

operationFunction · 0.85
hasHandlerFunction · 0.85
filterChangeFunction · 0.85
removeReadOnlyRangesFunction · 0.85
makeChangeInnerFunction · 0.85

Tested by

no test coverage detected