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

Function filterSelectionChange

external/.scrollLibs.js:6921–6943  ·  view source on GitHub ↗
(doc, sel, options)

Source from the content-addressed store, hash-verified

6919 // Give beforeSelectionChange handlers a change to influence a
6920 // selection update.
6921 function filterSelectionChange(doc, sel, options) {
6922 var obj = {
6923 ranges: sel.ranges,
6924 update: function (ranges) {
6925 var this$1 = this
6926
6927 this.ranges = []
6928 for (var i = 0; i < ranges.length; i++) {
6929 this$1.ranges[i] = new Range(clipPos(doc, ranges[i].anchor), clipPos(doc, ranges[i].head))
6930 }
6931 },
6932 origin: options && options.origin
6933 }
6934 signal(doc, "beforeSelectionChange", doc, obj)
6935 if (doc.cm) {
6936 signal(doc.cm, "beforeSelectionChange", doc.cm, obj)
6937 }
6938 if (obj.ranges != sel.ranges) {
6939 return normalizeSelection(doc.cm, obj.ranges, obj.ranges.length - 1)
6940 } else {
6941 return sel
6942 }
6943 }
6944
6945 function setSelectionReplaceHistory(doc, sel, options) {
6946 var done = doc.history.done,

Callers 1

setSelectionNoUndoFunction · 0.85

Calls 3

clipPosFunction · 0.85
signalFunction · 0.85
normalizeSelectionFunction · 0.85

Tested by

no test coverage detected