@codemirror/state 6.1.1 → 6.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.cjs +79 -65
- package/dist/index.d.ts +12 -0
- package/dist/index.js +79 -65
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 6.1.3 (2022-11-10)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Avoid unnecessary calls to computed facet getters when a state is reconfigured but no dependencies of the computed facet change.
|
|
6
|
+
|
|
7
|
+
Fix an infinite loop in `RangeSet.eq` when the `to` parameter isn't given.
|
|
8
|
+
|
|
9
|
+
## 6.1.2 (2022-09-21)
|
|
10
|
+
|
|
11
|
+
### Bug fixes
|
|
12
|
+
|
|
13
|
+
Fix an issue where, when multiple transaction extenders took effect, only the highest-precedence one was actually included in the transaction.
|
|
14
|
+
|
|
1
15
|
## 6.1.1 (2022-08-03)
|
|
2
16
|
|
|
3
17
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -31,10 +31,10 @@ class Text {
|
|
|
31
31
|
*/
|
|
32
32
|
replace(from, to, text) {
|
|
33
33
|
let parts = [];
|
|
34
|
-
this.decompose(0, from, parts, 2 /* To */);
|
|
34
|
+
this.decompose(0, from, parts, 2 /* Open.To */);
|
|
35
35
|
if (text.length)
|
|
36
|
-
text.decompose(0, text.length, parts, 1 /* From */ | 2 /* To */);
|
|
37
|
-
this.decompose(to, this.length, parts, 1 /* From */);
|
|
36
|
+
text.decompose(0, text.length, parts, 1 /* Open.From */ | 2 /* Open.To */);
|
|
37
|
+
this.decompose(to, this.length, parts, 1 /* Open.From */);
|
|
38
38
|
return TextNode.from(parts, this.length - (to - from) + text.length);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -124,7 +124,7 @@ class Text {
|
|
|
124
124
|
throw new RangeError("A document must have at least one line");
|
|
125
125
|
if (text.length == 1 && !text[0])
|
|
126
126
|
return Text.empty;
|
|
127
|
-
return text.length <= 32 /* Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
|
|
127
|
+
return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
// Leaves store an array of line strings. There are always line breaks
|
|
@@ -150,10 +150,10 @@ class TextLeaf extends Text {
|
|
|
150
150
|
decompose(from, to, target, open) {
|
|
151
151
|
let text = from <= 0 && to >= this.length ? this
|
|
152
152
|
: new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
|
|
153
|
-
if (open & 1 /* From */) {
|
|
153
|
+
if (open & 1 /* Open.From */) {
|
|
154
154
|
let prev = target.pop();
|
|
155
155
|
let joined = appendText(text.text, prev.text.slice(), 0, text.length);
|
|
156
|
-
if (joined.length <= 32 /* Branch */) {
|
|
156
|
+
if (joined.length <= 32 /* Tree.Branch */) {
|
|
157
157
|
target.push(new TextLeaf(joined, prev.length + text.length));
|
|
158
158
|
}
|
|
159
159
|
else {
|
|
@@ -170,7 +170,7 @@ class TextLeaf extends Text {
|
|
|
170
170
|
return super.replace(from, to, text);
|
|
171
171
|
let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);
|
|
172
172
|
let newLen = this.length + text.length - (to - from);
|
|
173
|
-
if (lines.length <= 32 /* Branch */)
|
|
173
|
+
if (lines.length <= 32 /* Tree.Branch */)
|
|
174
174
|
return new TextLeaf(lines, newLen);
|
|
175
175
|
return TextNode.from(TextLeaf.split(lines, []), newLen);
|
|
176
176
|
}
|
|
@@ -196,7 +196,7 @@ class TextLeaf extends Text {
|
|
|
196
196
|
for (let line of text) {
|
|
197
197
|
part.push(line);
|
|
198
198
|
len += line.length + 1;
|
|
199
|
-
if (part.length == 32 /* Branch */) {
|
|
199
|
+
if (part.length == 32 /* Tree.Branch */) {
|
|
200
200
|
target.push(new TextLeaf(part, len));
|
|
201
201
|
part = [];
|
|
202
202
|
len = -1;
|
|
@@ -233,7 +233,7 @@ class TextNode extends Text {
|
|
|
233
233
|
for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
|
|
234
234
|
let child = this.children[i], end = pos + child.length;
|
|
235
235
|
if (from <= end && to >= pos) {
|
|
236
|
-
let childOpen = open & ((pos <= from ? 1 /* From */ : 0) | (end >= to ? 2 /* To */ : 0));
|
|
236
|
+
let childOpen = open & ((pos <= from ? 1 /* Open.From */ : 0) | (end >= to ? 2 /* Open.To */ : 0));
|
|
237
237
|
if (pos >= from && end <= to && !childOpen)
|
|
238
238
|
target.push(child);
|
|
239
239
|
else
|
|
@@ -252,8 +252,8 @@ class TextNode extends Text {
|
|
|
252
252
|
if (from >= pos && to <= end) {
|
|
253
253
|
let updated = child.replace(from - pos, to - pos, text);
|
|
254
254
|
let totalLines = this.lines - child.lines + updated.lines;
|
|
255
|
-
if (updated.lines < (totalLines >> (5 /* BranchShift */ - 1)) &&
|
|
256
|
-
updated.lines > (totalLines >> (5 /* BranchShift */ + 1))) {
|
|
255
|
+
if (updated.lines < (totalLines >> (5 /* Tree.BranchShift */ - 1)) &&
|
|
256
|
+
updated.lines > (totalLines >> (5 /* Tree.BranchShift */ + 1))) {
|
|
257
257
|
let copy = this.children.slice();
|
|
258
258
|
copy[i] = updated;
|
|
259
259
|
return new TextNode(copy, this.length - (to - from) + text.length);
|
|
@@ -299,13 +299,13 @@ class TextNode extends Text {
|
|
|
299
299
|
let lines = 0;
|
|
300
300
|
for (let ch of children)
|
|
301
301
|
lines += ch.lines;
|
|
302
|
-
if (lines < 32 /* Branch */) {
|
|
302
|
+
if (lines < 32 /* Tree.Branch */) {
|
|
303
303
|
let flat = [];
|
|
304
304
|
for (let ch of children)
|
|
305
305
|
ch.flatten(flat);
|
|
306
306
|
return new TextLeaf(flat, length);
|
|
307
307
|
}
|
|
308
|
-
let chunk = Math.max(32 /* Branch */, lines >> 5 /* BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
|
|
308
|
+
let chunk = Math.max(32 /* Tree.Branch */, lines >> 5 /* Tree.BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
|
|
309
309
|
let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
|
|
310
310
|
function add(child) {
|
|
311
311
|
let last;
|
|
@@ -319,7 +319,7 @@ class TextNode extends Text {
|
|
|
319
319
|
}
|
|
320
320
|
else if (child instanceof TextLeaf && currentLines &&
|
|
321
321
|
(last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf &&
|
|
322
|
-
child.lines + last.lines <= 32 /* Branch */) {
|
|
322
|
+
child.lines + last.lines <= 32 /* Tree.Branch */) {
|
|
323
323
|
currentLines += child.lines;
|
|
324
324
|
currentLen += child.length + 1;
|
|
325
325
|
currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length);
|
|
@@ -1316,12 +1316,12 @@ class SelectionRange {
|
|
|
1316
1316
|
The anchor of the range—the side that doesn't move when you
|
|
1317
1317
|
extend it.
|
|
1318
1318
|
*/
|
|
1319
|
-
get anchor() { return this.flags & 16 /* Inverted */ ? this.to : this.from; }
|
|
1319
|
+
get anchor() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.to : this.from; }
|
|
1320
1320
|
/**
|
|
1321
1321
|
The head of the range, which is moved when the range is
|
|
1322
1322
|
[extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
|
|
1323
1323
|
*/
|
|
1324
|
-
get head() { return this.flags & 16 /* Inverted */ ? this.from : this.to; }
|
|
1324
|
+
get head() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.from : this.to; }
|
|
1325
1325
|
/**
|
|
1326
1326
|
True when `anchor` and `head` are at the same position.
|
|
1327
1327
|
*/
|
|
@@ -1332,13 +1332,13 @@ class SelectionRange {
|
|
|
1332
1332
|
the character before its position, 1 the character after, and 0
|
|
1333
1333
|
means no association.
|
|
1334
1334
|
*/
|
|
1335
|
-
get assoc() { return this.flags & 4 /* AssocBefore */ ? -1 : this.flags & 8 /* AssocAfter */ ? 1 : 0; }
|
|
1335
|
+
get assoc() { return this.flags & 4 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 8 /* RangeFlag.AssocAfter */ ? 1 : 0; }
|
|
1336
1336
|
/**
|
|
1337
1337
|
The bidirectional text level associated with this cursor, if
|
|
1338
1338
|
any.
|
|
1339
1339
|
*/
|
|
1340
1340
|
get bidiLevel() {
|
|
1341
|
-
let level = this.flags & 3 /* BidiLevelMask */;
|
|
1341
|
+
let level = this.flags & 3 /* RangeFlag.BidiLevelMask */;
|
|
1342
1342
|
return level == 3 ? null : level;
|
|
1343
1343
|
}
|
|
1344
1344
|
/**
|
|
@@ -1348,8 +1348,8 @@ class SelectionRange {
|
|
|
1348
1348
|
lines of different length.
|
|
1349
1349
|
*/
|
|
1350
1350
|
get goalColumn() {
|
|
1351
|
-
let value = this.flags >> 5 /* GoalColumnOffset */;
|
|
1352
|
-
return value == 33554431 /* NoGoalColumn */ ? undefined : value;
|
|
1351
|
+
let value = this.flags >> 5 /* RangeFlag.GoalColumnOffset */;
|
|
1352
|
+
return value == 33554431 /* RangeFlag.NoGoalColumn */ ? undefined : value;
|
|
1353
1353
|
}
|
|
1354
1354
|
/**
|
|
1355
1355
|
Map this range through a change, producing a valid range in the
|
|
@@ -1509,17 +1509,17 @@ class EditorSelection {
|
|
|
1509
1509
|
safely ignore the optional arguments in most situations.
|
|
1510
1510
|
*/
|
|
1511
1511
|
static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
|
|
1512
|
-
return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* AssocBefore */ : 8 /* AssocAfter */) |
|
|
1512
|
+
return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* RangeFlag.AssocBefore */ : 8 /* RangeFlag.AssocAfter */) |
|
|
1513
1513
|
(bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
|
|
1514
|
-
((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */));
|
|
1514
|
+
((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */));
|
|
1515
1515
|
}
|
|
1516
1516
|
/**
|
|
1517
1517
|
Create a selection range.
|
|
1518
1518
|
*/
|
|
1519
1519
|
static range(anchor, head, goalColumn) {
|
|
1520
|
-
let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */;
|
|
1521
|
-
return head < anchor ? SelectionRange.create(head, anchor, 16 /* Inverted */ | goal | 8 /* AssocAfter */)
|
|
1522
|
-
: SelectionRange.create(anchor, head, goal | (head > anchor ? 4 /* AssocBefore */ : 0));
|
|
1520
|
+
let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */;
|
|
1521
|
+
return head < anchor ? SelectionRange.create(head, anchor, 16 /* RangeFlag.Inverted */ | goal | 8 /* RangeFlag.AssocAfter */)
|
|
1522
|
+
: SelectionRange.create(anchor, head, goal | (head > anchor ? 4 /* RangeFlag.AssocBefore */ : 0));
|
|
1523
1523
|
}
|
|
1524
1524
|
/**
|
|
1525
1525
|
@internal
|
|
@@ -1592,7 +1592,7 @@ class Facet {
|
|
|
1592
1592
|
Returns an extension that adds the given value to this facet.
|
|
1593
1593
|
*/
|
|
1594
1594
|
of(value) {
|
|
1595
|
-
return new FacetProvider([], this, 0 /* Static */, value);
|
|
1595
|
+
return new FacetProvider([], this, 0 /* Provider.Static */, value);
|
|
1596
1596
|
}
|
|
1597
1597
|
/**
|
|
1598
1598
|
Create an extension that computes a value for the facet from a
|
|
@@ -1606,7 +1606,7 @@ class Facet {
|
|
|
1606
1606
|
compute(deps, get) {
|
|
1607
1607
|
if (this.isStatic)
|
|
1608
1608
|
throw new Error("Can't compute a static facet");
|
|
1609
|
-
return new FacetProvider(deps, this, 1 /* Single */, get);
|
|
1609
|
+
return new FacetProvider(deps, this, 1 /* Provider.Single */, get);
|
|
1610
1610
|
}
|
|
1611
1611
|
/**
|
|
1612
1612
|
Create an extension that computes zero or more values for this
|
|
@@ -1615,7 +1615,7 @@ class Facet {
|
|
|
1615
1615
|
computeN(deps, get) {
|
|
1616
1616
|
if (this.isStatic)
|
|
1617
1617
|
throw new Error("Can't compute a static facet");
|
|
1618
|
-
return new FacetProvider(deps, this, 2 /* Multi */, get);
|
|
1618
|
+
return new FacetProvider(deps, this, 2 /* Provider.Multi */, get);
|
|
1619
1619
|
}
|
|
1620
1620
|
from(field, get) {
|
|
1621
1621
|
if (!get)
|
|
@@ -1638,7 +1638,7 @@ class FacetProvider {
|
|
|
1638
1638
|
var _a;
|
|
1639
1639
|
let getter = this.value;
|
|
1640
1640
|
let compare = this.facet.compareInput;
|
|
1641
|
-
let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Multi */;
|
|
1641
|
+
let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Provider.Multi */;
|
|
1642
1642
|
let depDoc = false, depSel = false, depAddrs = [];
|
|
1643
1643
|
for (let dep of this.dependencies) {
|
|
1644
1644
|
if (dep == "doc")
|
|
@@ -1651,33 +1651,35 @@ class FacetProvider {
|
|
|
1651
1651
|
return {
|
|
1652
1652
|
create(state) {
|
|
1653
1653
|
state.values[idx] = getter(state);
|
|
1654
|
-
return 1 /* Changed */;
|
|
1654
|
+
return 1 /* SlotStatus.Changed */;
|
|
1655
1655
|
},
|
|
1656
1656
|
update(state, tr) {
|
|
1657
1657
|
if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll(state, depAddrs)) {
|
|
1658
1658
|
let newVal = getter(state);
|
|
1659
1659
|
if (multi ? !compareArray(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
|
|
1660
1660
|
state.values[idx] = newVal;
|
|
1661
|
-
return 1 /* Changed */;
|
|
1661
|
+
return 1 /* SlotStatus.Changed */;
|
|
1662
1662
|
}
|
|
1663
1663
|
}
|
|
1664
1664
|
return 0;
|
|
1665
1665
|
},
|
|
1666
1666
|
reconfigure: (state, oldState) => {
|
|
1667
|
-
let newVal =
|
|
1668
|
-
let oldAddr = oldState.config.address[id];
|
|
1667
|
+
let newVal, oldAddr = oldState.config.address[id];
|
|
1669
1668
|
if (oldAddr != null) {
|
|
1670
1669
|
let oldVal = getAddr(oldState, oldAddr);
|
|
1671
1670
|
if (this.dependencies.every(dep => {
|
|
1672
1671
|
return dep instanceof Facet ? oldState.facet(dep) === state.facet(dep) :
|
|
1673
1672
|
dep instanceof StateField ? oldState.field(dep, false) == state.field(dep, false) : true;
|
|
1674
|
-
}) || (multi ? compareArray(newVal, oldVal, compare) : compare(newVal, oldVal))) {
|
|
1673
|
+
}) || (multi ? compareArray(newVal = getter(state), oldVal, compare) : compare(newVal = getter(state), oldVal))) {
|
|
1675
1674
|
state.values[idx] = oldVal;
|
|
1676
1675
|
return 0;
|
|
1677
1676
|
}
|
|
1678
1677
|
}
|
|
1678
|
+
else {
|
|
1679
|
+
newVal = getter(state);
|
|
1680
|
+
}
|
|
1679
1681
|
state.values[idx] = newVal;
|
|
1680
|
-
return 1 /* Changed */;
|
|
1682
|
+
return 1 /* SlotStatus.Changed */;
|
|
1681
1683
|
}
|
|
1682
1684
|
};
|
|
1683
1685
|
}
|
|
@@ -1693,7 +1695,7 @@ function compareArray(a, b, compare) {
|
|
|
1693
1695
|
function ensureAll(state, addrs) {
|
|
1694
1696
|
let changed = false;
|
|
1695
1697
|
for (let addr of addrs)
|
|
1696
|
-
if (ensureAddr(state, addr) & 1 /* Changed */)
|
|
1698
|
+
if (ensureAddr(state, addr) & 1 /* SlotStatus.Changed */)
|
|
1697
1699
|
changed = true;
|
|
1698
1700
|
return changed;
|
|
1699
1701
|
}
|
|
@@ -1706,7 +1708,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1706
1708
|
let values = [];
|
|
1707
1709
|
for (let i = 0; i < providerAddrs.length; i++) {
|
|
1708
1710
|
let value = getAddr(state, providerAddrs[i]);
|
|
1709
|
-
if (providerTypes[i] == 2 /* Multi */)
|
|
1711
|
+
if (providerTypes[i] == 2 /* Provider.Multi */)
|
|
1710
1712
|
for (let val of value)
|
|
1711
1713
|
values.push(val);
|
|
1712
1714
|
else
|
|
@@ -1719,7 +1721,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1719
1721
|
for (let addr of providerAddrs)
|
|
1720
1722
|
ensureAddr(state, addr);
|
|
1721
1723
|
state.values[idx] = get(state);
|
|
1722
|
-
return 1 /* Changed */;
|
|
1724
|
+
return 1 /* SlotStatus.Changed */;
|
|
1723
1725
|
},
|
|
1724
1726
|
update(state, tr) {
|
|
1725
1727
|
if (!ensureAll(state, dynamic))
|
|
@@ -1728,7 +1730,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1728
1730
|
if (facet.compare(value, state.values[idx]))
|
|
1729
1731
|
return 0;
|
|
1730
1732
|
state.values[idx] = value;
|
|
1731
|
-
return 1 /* Changed */;
|
|
1733
|
+
return 1 /* SlotStatus.Changed */;
|
|
1732
1734
|
},
|
|
1733
1735
|
reconfigure(state, oldState) {
|
|
1734
1736
|
let depChanged = ensureAll(state, providerAddrs);
|
|
@@ -1743,7 +1745,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1743
1745
|
return 0;
|
|
1744
1746
|
}
|
|
1745
1747
|
state.values[idx] = value;
|
|
1746
|
-
return 1 /* Changed */;
|
|
1748
|
+
return 1 /* SlotStatus.Changed */;
|
|
1747
1749
|
}
|
|
1748
1750
|
};
|
|
1749
1751
|
}
|
|
@@ -1793,7 +1795,7 @@ class StateField {
|
|
|
1793
1795
|
return {
|
|
1794
1796
|
create: (state) => {
|
|
1795
1797
|
state.values[idx] = this.create(state);
|
|
1796
|
-
return 1 /* Changed */;
|
|
1798
|
+
return 1 /* SlotStatus.Changed */;
|
|
1797
1799
|
},
|
|
1798
1800
|
update: (state, tr) => {
|
|
1799
1801
|
let oldVal = state.values[idx];
|
|
@@ -1801,7 +1803,7 @@ class StateField {
|
|
|
1801
1803
|
if (this.compareF(oldVal, value))
|
|
1802
1804
|
return 0;
|
|
1803
1805
|
state.values[idx] = value;
|
|
1804
|
-
return 1 /* Changed */;
|
|
1806
|
+
return 1 /* SlotStatus.Changed */;
|
|
1805
1807
|
},
|
|
1806
1808
|
reconfigure: (state, oldState) => {
|
|
1807
1809
|
if (oldState.config.address[this.id] != null) {
|
|
@@ -1809,7 +1811,7 @@ class StateField {
|
|
|
1809
1811
|
return 0;
|
|
1810
1812
|
}
|
|
1811
1813
|
state.values[idx] = this.create(state);
|
|
1812
|
-
return 1 /* Changed */;
|
|
1814
|
+
return 1 /* SlotStatus.Changed */;
|
|
1813
1815
|
}
|
|
1814
1816
|
};
|
|
1815
1817
|
}
|
|
@@ -1918,7 +1920,7 @@ class Configuration {
|
|
|
1918
1920
|
this.facets = facets;
|
|
1919
1921
|
this.statusTemplate = [];
|
|
1920
1922
|
while (this.statusTemplate.length < dynamicSlots.length)
|
|
1921
|
-
this.statusTemplate.push(0 /* Unresolved */);
|
|
1923
|
+
this.statusTemplate.push(0 /* SlotStatus.Unresolved */);
|
|
1922
1924
|
}
|
|
1923
1925
|
staticFacet(facet) {
|
|
1924
1926
|
let addr = this.address[facet.id];
|
|
@@ -1945,7 +1947,7 @@ class Configuration {
|
|
|
1945
1947
|
for (let id in facets) {
|
|
1946
1948
|
let providers = facets[id], facet = providers[0].facet;
|
|
1947
1949
|
let oldProviders = oldFacets && oldFacets[id] || [];
|
|
1948
|
-
if (providers.every(p => p.type == 0 /* Static */)) {
|
|
1950
|
+
if (providers.every(p => p.type == 0 /* Provider.Static */)) {
|
|
1949
1951
|
address[facet.id] = (staticValues.length << 1) | 1;
|
|
1950
1952
|
if (sameArray(oldProviders, providers)) {
|
|
1951
1953
|
staticValues.push(oldState.facet(facet));
|
|
@@ -1957,7 +1959,7 @@ class Configuration {
|
|
|
1957
1959
|
}
|
|
1958
1960
|
else {
|
|
1959
1961
|
for (let p of providers) {
|
|
1960
|
-
if (p.type == 0 /* Static */) {
|
|
1962
|
+
if (p.type == 0 /* Provider.Static */) {
|
|
1961
1963
|
address[p.id] = (staticValues.length << 1) | 1;
|
|
1962
1964
|
staticValues.push(p.value);
|
|
1963
1965
|
}
|
|
@@ -2025,16 +2027,16 @@ function flatten(extension, compartments, newCompartments) {
|
|
|
2025
2027
|
}
|
|
2026
2028
|
function ensureAddr(state, addr) {
|
|
2027
2029
|
if (addr & 1)
|
|
2028
|
-
return 2 /* Computed */;
|
|
2030
|
+
return 2 /* SlotStatus.Computed */;
|
|
2029
2031
|
let idx = addr >> 1;
|
|
2030
2032
|
let status = state.status[idx];
|
|
2031
|
-
if (status == 4 /* Computing */)
|
|
2033
|
+
if (status == 4 /* SlotStatus.Computing */)
|
|
2032
2034
|
throw new Error("Cyclic dependency between fields and/or facets");
|
|
2033
|
-
if (status & 2 /* Computed */)
|
|
2035
|
+
if (status & 2 /* SlotStatus.Computed */)
|
|
2034
2036
|
return status;
|
|
2035
|
-
state.status[idx] = 4 /* Computing */;
|
|
2037
|
+
state.status[idx] = 4 /* SlotStatus.Computing */;
|
|
2036
2038
|
let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
|
|
2037
|
-
return state.status[idx] = 2 /* Computed */ | changed;
|
|
2039
|
+
return state.status[idx] = 2 /* SlotStatus.Computed */ | changed;
|
|
2038
2040
|
}
|
|
2039
2041
|
function getAddr(state, addr) {
|
|
2040
2042
|
return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
|
|
@@ -2471,7 +2473,7 @@ function extendTransaction(tr) {
|
|
|
2471
2473
|
for (let i = extenders.length - 1; i >= 0; i--) {
|
|
2472
2474
|
let extension = extenders[i](tr);
|
|
2473
2475
|
if (extension && Object.keys(extension).length)
|
|
2474
|
-
spec = mergeTransaction(
|
|
2476
|
+
spec = mergeTransaction(spec, resolveTransactionInner(state, extension, tr.changes.newLength), true);
|
|
2475
2477
|
}
|
|
2476
2478
|
return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
|
|
2477
2479
|
}
|
|
@@ -2810,6 +2812,18 @@ class EditorState {
|
|
|
2810
2812
|
/**
|
|
2811
2813
|
Find the values for a given language data field, provided by the
|
|
2812
2814
|
the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
|
|
2815
|
+
|
|
2816
|
+
Examples of language data fields are...
|
|
2817
|
+
|
|
2818
|
+
- [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
|
|
2819
|
+
comment syntax.
|
|
2820
|
+
- [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
|
|
2821
|
+
for providing language-specific completion sources.
|
|
2822
|
+
- [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
|
|
2823
|
+
characters that should be considered part of words in this
|
|
2824
|
+
language.
|
|
2825
|
+
- [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
|
|
2826
|
+
bracket closing behavior.
|
|
2813
2827
|
*/
|
|
2814
2828
|
languageDataAt(name, pos, side = -1) {
|
|
2815
2829
|
let values = [];
|
|
@@ -3081,7 +3095,7 @@ class Chunk {
|
|
|
3081
3095
|
}
|
|
3082
3096
|
}
|
|
3083
3097
|
between(offset, from, to, f) {
|
|
3084
|
-
for (let i = this.findIndex(from, -1000000000 /* Far */, true), e = this.findIndex(to, 1000000000 /* Far */, false, i); i < e; i++)
|
|
3098
|
+
for (let i = this.findIndex(from, -1000000000 /* C.Far */, true), e = this.findIndex(to, 1000000000 /* C.Far */, false, i); i < e; i++)
|
|
3085
3099
|
if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
|
|
3086
3100
|
return false;
|
|
3087
3101
|
}
|
|
@@ -3314,7 +3328,7 @@ class RangeSet {
|
|
|
3314
3328
|
*/
|
|
3315
3329
|
static eq(oldSets, newSets, from = 0, to) {
|
|
3316
3330
|
if (to == null)
|
|
3317
|
-
to = 1000000000 /* Far
|
|
3331
|
+
to = 1000000000 /* C.Far */ - 1;
|
|
3318
3332
|
let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
|
|
3319
3333
|
let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
|
|
3320
3334
|
if (a.length != b.length)
|
|
@@ -3409,8 +3423,8 @@ class RangeSetBuilder {
|
|
|
3409
3423
|
this.chunkPos = [];
|
|
3410
3424
|
this.chunkStart = -1;
|
|
3411
3425
|
this.last = null;
|
|
3412
|
-
this.lastFrom = -1000000000 /* Far */;
|
|
3413
|
-
this.lastTo = -1000000000 /* Far */;
|
|
3426
|
+
this.lastFrom = -1000000000 /* C.Far */;
|
|
3427
|
+
this.lastTo = -1000000000 /* C.Far */;
|
|
3414
3428
|
this.from = [];
|
|
3415
3429
|
this.to = [];
|
|
3416
3430
|
this.value = [];
|
|
@@ -3447,7 +3461,7 @@ class RangeSetBuilder {
|
|
|
3447
3461
|
throw new Error("Ranges must be added sorted by `from` position and `startSide`");
|
|
3448
3462
|
if (diff < 0)
|
|
3449
3463
|
return false;
|
|
3450
|
-
if (this.from.length == 250 /* ChunkSize */)
|
|
3464
|
+
if (this.from.length == 250 /* C.ChunkSize */)
|
|
3451
3465
|
this.finishChunk(true);
|
|
3452
3466
|
if (this.chunkStart < 0)
|
|
3453
3467
|
this.chunkStart = from;
|
|
@@ -3521,7 +3535,7 @@ class LayerCursor {
|
|
|
3521
3535
|
}
|
|
3522
3536
|
get startSide() { return this.value ? this.value.startSide : 0; }
|
|
3523
3537
|
get endSide() { return this.value ? this.value.endSide : 0; }
|
|
3524
|
-
goto(pos, side = -1000000000 /* Far */) {
|
|
3538
|
+
goto(pos, side = -1000000000 /* C.Far */) {
|
|
3525
3539
|
this.chunkIndex = this.rangeIndex = 0;
|
|
3526
3540
|
this.gotoInner(pos, side, false);
|
|
3527
3541
|
return this;
|
|
@@ -3550,7 +3564,7 @@ class LayerCursor {
|
|
|
3550
3564
|
next() {
|
|
3551
3565
|
for (;;) {
|
|
3552
3566
|
if (this.chunkIndex == this.layer.chunk.length) {
|
|
3553
|
-
this.from = this.to = 1000000000 /* Far */;
|
|
3567
|
+
this.from = this.to = 1000000000 /* C.Far */;
|
|
3554
3568
|
this.value = null;
|
|
3555
3569
|
break;
|
|
3556
3570
|
}
|
|
@@ -3604,7 +3618,7 @@ class HeapCursor {
|
|
|
3604
3618
|
return heap.length == 1 ? heap[0] : new HeapCursor(heap);
|
|
3605
3619
|
}
|
|
3606
3620
|
get startSide() { return this.value ? this.value.startSide : 0; }
|
|
3607
|
-
goto(pos, side = -1000000000 /* Far */) {
|
|
3621
|
+
goto(pos, side = -1000000000 /* C.Far */) {
|
|
3608
3622
|
for (let cur of this.heap)
|
|
3609
3623
|
cur.goto(pos, side);
|
|
3610
3624
|
for (let i = this.heap.length >> 1; i >= 0; i--)
|
|
@@ -3622,7 +3636,7 @@ class HeapCursor {
|
|
|
3622
3636
|
}
|
|
3623
3637
|
next() {
|
|
3624
3638
|
if (this.heap.length == 0) {
|
|
3625
|
-
this.from = this.to = 1000000000 /* Far */;
|
|
3639
|
+
this.from = this.to = 1000000000 /* C.Far */;
|
|
3626
3640
|
this.value = null;
|
|
3627
3641
|
this.rank = -1;
|
|
3628
3642
|
}
|
|
@@ -3666,12 +3680,12 @@ class SpanCursor {
|
|
|
3666
3680
|
this.point = null;
|
|
3667
3681
|
this.pointFrom = 0;
|
|
3668
3682
|
this.pointRank = 0;
|
|
3669
|
-
this.to = -1000000000 /* Far */;
|
|
3683
|
+
this.to = -1000000000 /* C.Far */;
|
|
3670
3684
|
this.endSide = 0;
|
|
3671
3685
|
this.openStart = -1;
|
|
3672
3686
|
this.cursor = HeapCursor.from(sets, skip, minPoint);
|
|
3673
3687
|
}
|
|
3674
|
-
goto(pos, side = -1000000000 /* Far */) {
|
|
3688
|
+
goto(pos, side = -1000000000 /* C.Far */) {
|
|
3675
3689
|
this.cursor.goto(pos, side);
|
|
3676
3690
|
this.active.length = this.activeTo.length = this.activeRank.length = 0;
|
|
3677
3691
|
this.minActive = -1;
|
|
@@ -3722,7 +3736,7 @@ class SpanCursor {
|
|
|
3722
3736
|
remove(trackOpen, a);
|
|
3723
3737
|
}
|
|
3724
3738
|
else if (!this.cursor.value) {
|
|
3725
|
-
this.to = this.endSide = 1000000000 /* Far */;
|
|
3739
|
+
this.to = this.endSide = 1000000000 /* C.Far */;
|
|
3726
3740
|
break;
|
|
3727
3741
|
}
|
|
3728
3742
|
else if (this.cursor.from > from) {
|
|
@@ -3827,7 +3841,7 @@ function insert(array, index, value) {
|
|
|
3827
3841
|
array[index] = value;
|
|
3828
3842
|
}
|
|
3829
3843
|
function findMinIndex(value, array) {
|
|
3830
|
-
let found = -1, foundPos = 1000000000 /* Far */;
|
|
3844
|
+
let found = -1, foundPos = 1000000000 /* C.Far */;
|
|
3831
3845
|
for (let i = 0; i < array.length; i++)
|
|
3832
3846
|
if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
|
|
3833
3847
|
found = i;
|
package/dist/index.d.ts
CHANGED
|
@@ -1228,6 +1228,18 @@ declare class EditorState {
|
|
|
1228
1228
|
/**
|
|
1229
1229
|
Find the values for a given language data field, provided by the
|
|
1230
1230
|
the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
|
|
1231
|
+
|
|
1232
|
+
Examples of language data fields are...
|
|
1233
|
+
|
|
1234
|
+
- [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
|
|
1235
|
+
comment syntax.
|
|
1236
|
+
- [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
|
|
1237
|
+
for providing language-specific completion sources.
|
|
1238
|
+
- [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
|
|
1239
|
+
characters that should be considered part of words in this
|
|
1240
|
+
language.
|
|
1241
|
+
- [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
|
|
1242
|
+
bracket closing behavior.
|
|
1231
1243
|
*/
|
|
1232
1244
|
languageDataAt<T>(name: string, pos: number, side?: -1 | 0 | 1): readonly T[];
|
|
1233
1245
|
/**
|
package/dist/index.js
CHANGED
|
@@ -27,10 +27,10 @@ class Text {
|
|
|
27
27
|
*/
|
|
28
28
|
replace(from, to, text) {
|
|
29
29
|
let parts = [];
|
|
30
|
-
this.decompose(0, from, parts, 2 /* To */);
|
|
30
|
+
this.decompose(0, from, parts, 2 /* Open.To */);
|
|
31
31
|
if (text.length)
|
|
32
|
-
text.decompose(0, text.length, parts, 1 /* From */ | 2 /* To */);
|
|
33
|
-
this.decompose(to, this.length, parts, 1 /* From */);
|
|
32
|
+
text.decompose(0, text.length, parts, 1 /* Open.From */ | 2 /* Open.To */);
|
|
33
|
+
this.decompose(to, this.length, parts, 1 /* Open.From */);
|
|
34
34
|
return TextNode.from(parts, this.length - (to - from) + text.length);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -120,7 +120,7 @@ class Text {
|
|
|
120
120
|
throw new RangeError("A document must have at least one line");
|
|
121
121
|
if (text.length == 1 && !text[0])
|
|
122
122
|
return Text.empty;
|
|
123
|
-
return text.length <= 32 /* Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
|
|
123
|
+
return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
// Leaves store an array of line strings. There are always line breaks
|
|
@@ -146,10 +146,10 @@ class TextLeaf extends Text {
|
|
|
146
146
|
decompose(from, to, target, open) {
|
|
147
147
|
let text = from <= 0 && to >= this.length ? this
|
|
148
148
|
: new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));
|
|
149
|
-
if (open & 1 /* From */) {
|
|
149
|
+
if (open & 1 /* Open.From */) {
|
|
150
150
|
let prev = target.pop();
|
|
151
151
|
let joined = appendText(text.text, prev.text.slice(), 0, text.length);
|
|
152
|
-
if (joined.length <= 32 /* Branch */) {
|
|
152
|
+
if (joined.length <= 32 /* Tree.Branch */) {
|
|
153
153
|
target.push(new TextLeaf(joined, prev.length + text.length));
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
@@ -166,7 +166,7 @@ class TextLeaf extends Text {
|
|
|
166
166
|
return super.replace(from, to, text);
|
|
167
167
|
let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);
|
|
168
168
|
let newLen = this.length + text.length - (to - from);
|
|
169
|
-
if (lines.length <= 32 /* Branch */)
|
|
169
|
+
if (lines.length <= 32 /* Tree.Branch */)
|
|
170
170
|
return new TextLeaf(lines, newLen);
|
|
171
171
|
return TextNode.from(TextLeaf.split(lines, []), newLen);
|
|
172
172
|
}
|
|
@@ -192,7 +192,7 @@ class TextLeaf extends Text {
|
|
|
192
192
|
for (let line of text) {
|
|
193
193
|
part.push(line);
|
|
194
194
|
len += line.length + 1;
|
|
195
|
-
if (part.length == 32 /* Branch */) {
|
|
195
|
+
if (part.length == 32 /* Tree.Branch */) {
|
|
196
196
|
target.push(new TextLeaf(part, len));
|
|
197
197
|
part = [];
|
|
198
198
|
len = -1;
|
|
@@ -229,7 +229,7 @@ class TextNode extends Text {
|
|
|
229
229
|
for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {
|
|
230
230
|
let child = this.children[i], end = pos + child.length;
|
|
231
231
|
if (from <= end && to >= pos) {
|
|
232
|
-
let childOpen = open & ((pos <= from ? 1 /* From */ : 0) | (end >= to ? 2 /* To */ : 0));
|
|
232
|
+
let childOpen = open & ((pos <= from ? 1 /* Open.From */ : 0) | (end >= to ? 2 /* Open.To */ : 0));
|
|
233
233
|
if (pos >= from && end <= to && !childOpen)
|
|
234
234
|
target.push(child);
|
|
235
235
|
else
|
|
@@ -248,8 +248,8 @@ class TextNode extends Text {
|
|
|
248
248
|
if (from >= pos && to <= end) {
|
|
249
249
|
let updated = child.replace(from - pos, to - pos, text);
|
|
250
250
|
let totalLines = this.lines - child.lines + updated.lines;
|
|
251
|
-
if (updated.lines < (totalLines >> (5 /* BranchShift */ - 1)) &&
|
|
252
|
-
updated.lines > (totalLines >> (5 /* BranchShift */ + 1))) {
|
|
251
|
+
if (updated.lines < (totalLines >> (5 /* Tree.BranchShift */ - 1)) &&
|
|
252
|
+
updated.lines > (totalLines >> (5 /* Tree.BranchShift */ + 1))) {
|
|
253
253
|
let copy = this.children.slice();
|
|
254
254
|
copy[i] = updated;
|
|
255
255
|
return new TextNode(copy, this.length - (to - from) + text.length);
|
|
@@ -295,13 +295,13 @@ class TextNode extends Text {
|
|
|
295
295
|
let lines = 0;
|
|
296
296
|
for (let ch of children)
|
|
297
297
|
lines += ch.lines;
|
|
298
|
-
if (lines < 32 /* Branch */) {
|
|
298
|
+
if (lines < 32 /* Tree.Branch */) {
|
|
299
299
|
let flat = [];
|
|
300
300
|
for (let ch of children)
|
|
301
301
|
ch.flatten(flat);
|
|
302
302
|
return new TextLeaf(flat, length);
|
|
303
303
|
}
|
|
304
|
-
let chunk = Math.max(32 /* Branch */, lines >> 5 /* BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
|
|
304
|
+
let chunk = Math.max(32 /* Tree.Branch */, lines >> 5 /* Tree.BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;
|
|
305
305
|
let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];
|
|
306
306
|
function add(child) {
|
|
307
307
|
let last;
|
|
@@ -315,7 +315,7 @@ class TextNode extends Text {
|
|
|
315
315
|
}
|
|
316
316
|
else if (child instanceof TextLeaf && currentLines &&
|
|
317
317
|
(last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf &&
|
|
318
|
-
child.lines + last.lines <= 32 /* Branch */) {
|
|
318
|
+
child.lines + last.lines <= 32 /* Tree.Branch */) {
|
|
319
319
|
currentLines += child.lines;
|
|
320
320
|
currentLen += child.length + 1;
|
|
321
321
|
currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length);
|
|
@@ -1311,12 +1311,12 @@ class SelectionRange {
|
|
|
1311
1311
|
The anchor of the range—the side that doesn't move when you
|
|
1312
1312
|
extend it.
|
|
1313
1313
|
*/
|
|
1314
|
-
get anchor() { return this.flags & 16 /* Inverted */ ? this.to : this.from; }
|
|
1314
|
+
get anchor() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.to : this.from; }
|
|
1315
1315
|
/**
|
|
1316
1316
|
The head of the range, which is moved when the range is
|
|
1317
1317
|
[extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
|
|
1318
1318
|
*/
|
|
1319
|
-
get head() { return this.flags & 16 /* Inverted */ ? this.from : this.to; }
|
|
1319
|
+
get head() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.from : this.to; }
|
|
1320
1320
|
/**
|
|
1321
1321
|
True when `anchor` and `head` are at the same position.
|
|
1322
1322
|
*/
|
|
@@ -1327,13 +1327,13 @@ class SelectionRange {
|
|
|
1327
1327
|
the character before its position, 1 the character after, and 0
|
|
1328
1328
|
means no association.
|
|
1329
1329
|
*/
|
|
1330
|
-
get assoc() { return this.flags & 4 /* AssocBefore */ ? -1 : this.flags & 8 /* AssocAfter */ ? 1 : 0; }
|
|
1330
|
+
get assoc() { return this.flags & 4 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 8 /* RangeFlag.AssocAfter */ ? 1 : 0; }
|
|
1331
1331
|
/**
|
|
1332
1332
|
The bidirectional text level associated with this cursor, if
|
|
1333
1333
|
any.
|
|
1334
1334
|
*/
|
|
1335
1335
|
get bidiLevel() {
|
|
1336
|
-
let level = this.flags & 3 /* BidiLevelMask */;
|
|
1336
|
+
let level = this.flags & 3 /* RangeFlag.BidiLevelMask */;
|
|
1337
1337
|
return level == 3 ? null : level;
|
|
1338
1338
|
}
|
|
1339
1339
|
/**
|
|
@@ -1343,8 +1343,8 @@ class SelectionRange {
|
|
|
1343
1343
|
lines of different length.
|
|
1344
1344
|
*/
|
|
1345
1345
|
get goalColumn() {
|
|
1346
|
-
let value = this.flags >> 5 /* GoalColumnOffset */;
|
|
1347
|
-
return value == 33554431 /* NoGoalColumn */ ? undefined : value;
|
|
1346
|
+
let value = this.flags >> 5 /* RangeFlag.GoalColumnOffset */;
|
|
1347
|
+
return value == 33554431 /* RangeFlag.NoGoalColumn */ ? undefined : value;
|
|
1348
1348
|
}
|
|
1349
1349
|
/**
|
|
1350
1350
|
Map this range through a change, producing a valid range in the
|
|
@@ -1504,17 +1504,17 @@ class EditorSelection {
|
|
|
1504
1504
|
safely ignore the optional arguments in most situations.
|
|
1505
1505
|
*/
|
|
1506
1506
|
static cursor(pos, assoc = 0, bidiLevel, goalColumn) {
|
|
1507
|
-
return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* AssocBefore */ : 8 /* AssocAfter */) |
|
|
1507
|
+
return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* RangeFlag.AssocBefore */ : 8 /* RangeFlag.AssocAfter */) |
|
|
1508
1508
|
(bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |
|
|
1509
|
-
((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */));
|
|
1509
|
+
((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */));
|
|
1510
1510
|
}
|
|
1511
1511
|
/**
|
|
1512
1512
|
Create a selection range.
|
|
1513
1513
|
*/
|
|
1514
1514
|
static range(anchor, head, goalColumn) {
|
|
1515
|
-
let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* NoGoalColumn */) << 5 /* GoalColumnOffset */;
|
|
1516
|
-
return head < anchor ? SelectionRange.create(head, anchor, 16 /* Inverted */ | goal | 8 /* AssocAfter */)
|
|
1517
|
-
: SelectionRange.create(anchor, head, goal | (head > anchor ? 4 /* AssocBefore */ : 0));
|
|
1515
|
+
let goal = (goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */;
|
|
1516
|
+
return head < anchor ? SelectionRange.create(head, anchor, 16 /* RangeFlag.Inverted */ | goal | 8 /* RangeFlag.AssocAfter */)
|
|
1517
|
+
: SelectionRange.create(anchor, head, goal | (head > anchor ? 4 /* RangeFlag.AssocBefore */ : 0));
|
|
1518
1518
|
}
|
|
1519
1519
|
/**
|
|
1520
1520
|
@internal
|
|
@@ -1587,7 +1587,7 @@ class Facet {
|
|
|
1587
1587
|
Returns an extension that adds the given value to this facet.
|
|
1588
1588
|
*/
|
|
1589
1589
|
of(value) {
|
|
1590
|
-
return new FacetProvider([], this, 0 /* Static */, value);
|
|
1590
|
+
return new FacetProvider([], this, 0 /* Provider.Static */, value);
|
|
1591
1591
|
}
|
|
1592
1592
|
/**
|
|
1593
1593
|
Create an extension that computes a value for the facet from a
|
|
@@ -1601,7 +1601,7 @@ class Facet {
|
|
|
1601
1601
|
compute(deps, get) {
|
|
1602
1602
|
if (this.isStatic)
|
|
1603
1603
|
throw new Error("Can't compute a static facet");
|
|
1604
|
-
return new FacetProvider(deps, this, 1 /* Single */, get);
|
|
1604
|
+
return new FacetProvider(deps, this, 1 /* Provider.Single */, get);
|
|
1605
1605
|
}
|
|
1606
1606
|
/**
|
|
1607
1607
|
Create an extension that computes zero or more values for this
|
|
@@ -1610,7 +1610,7 @@ class Facet {
|
|
|
1610
1610
|
computeN(deps, get) {
|
|
1611
1611
|
if (this.isStatic)
|
|
1612
1612
|
throw new Error("Can't compute a static facet");
|
|
1613
|
-
return new FacetProvider(deps, this, 2 /* Multi */, get);
|
|
1613
|
+
return new FacetProvider(deps, this, 2 /* Provider.Multi */, get);
|
|
1614
1614
|
}
|
|
1615
1615
|
from(field, get) {
|
|
1616
1616
|
if (!get)
|
|
@@ -1633,7 +1633,7 @@ class FacetProvider {
|
|
|
1633
1633
|
var _a;
|
|
1634
1634
|
let getter = this.value;
|
|
1635
1635
|
let compare = this.facet.compareInput;
|
|
1636
|
-
let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Multi */;
|
|
1636
|
+
let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Provider.Multi */;
|
|
1637
1637
|
let depDoc = false, depSel = false, depAddrs = [];
|
|
1638
1638
|
for (let dep of this.dependencies) {
|
|
1639
1639
|
if (dep == "doc")
|
|
@@ -1646,33 +1646,35 @@ class FacetProvider {
|
|
|
1646
1646
|
return {
|
|
1647
1647
|
create(state) {
|
|
1648
1648
|
state.values[idx] = getter(state);
|
|
1649
|
-
return 1 /* Changed */;
|
|
1649
|
+
return 1 /* SlotStatus.Changed */;
|
|
1650
1650
|
},
|
|
1651
1651
|
update(state, tr) {
|
|
1652
1652
|
if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll(state, depAddrs)) {
|
|
1653
1653
|
let newVal = getter(state);
|
|
1654
1654
|
if (multi ? !compareArray(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {
|
|
1655
1655
|
state.values[idx] = newVal;
|
|
1656
|
-
return 1 /* Changed */;
|
|
1656
|
+
return 1 /* SlotStatus.Changed */;
|
|
1657
1657
|
}
|
|
1658
1658
|
}
|
|
1659
1659
|
return 0;
|
|
1660
1660
|
},
|
|
1661
1661
|
reconfigure: (state, oldState) => {
|
|
1662
|
-
let newVal =
|
|
1663
|
-
let oldAddr = oldState.config.address[id];
|
|
1662
|
+
let newVal, oldAddr = oldState.config.address[id];
|
|
1664
1663
|
if (oldAddr != null) {
|
|
1665
1664
|
let oldVal = getAddr(oldState, oldAddr);
|
|
1666
1665
|
if (this.dependencies.every(dep => {
|
|
1667
1666
|
return dep instanceof Facet ? oldState.facet(dep) === state.facet(dep) :
|
|
1668
1667
|
dep instanceof StateField ? oldState.field(dep, false) == state.field(dep, false) : true;
|
|
1669
|
-
}) || (multi ? compareArray(newVal, oldVal, compare) : compare(newVal, oldVal))) {
|
|
1668
|
+
}) || (multi ? compareArray(newVal = getter(state), oldVal, compare) : compare(newVal = getter(state), oldVal))) {
|
|
1670
1669
|
state.values[idx] = oldVal;
|
|
1671
1670
|
return 0;
|
|
1672
1671
|
}
|
|
1673
1672
|
}
|
|
1673
|
+
else {
|
|
1674
|
+
newVal = getter(state);
|
|
1675
|
+
}
|
|
1674
1676
|
state.values[idx] = newVal;
|
|
1675
|
-
return 1 /* Changed */;
|
|
1677
|
+
return 1 /* SlotStatus.Changed */;
|
|
1676
1678
|
}
|
|
1677
1679
|
};
|
|
1678
1680
|
}
|
|
@@ -1688,7 +1690,7 @@ function compareArray(a, b, compare) {
|
|
|
1688
1690
|
function ensureAll(state, addrs) {
|
|
1689
1691
|
let changed = false;
|
|
1690
1692
|
for (let addr of addrs)
|
|
1691
|
-
if (ensureAddr(state, addr) & 1 /* Changed */)
|
|
1693
|
+
if (ensureAddr(state, addr) & 1 /* SlotStatus.Changed */)
|
|
1692
1694
|
changed = true;
|
|
1693
1695
|
return changed;
|
|
1694
1696
|
}
|
|
@@ -1701,7 +1703,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1701
1703
|
let values = [];
|
|
1702
1704
|
for (let i = 0; i < providerAddrs.length; i++) {
|
|
1703
1705
|
let value = getAddr(state, providerAddrs[i]);
|
|
1704
|
-
if (providerTypes[i] == 2 /* Multi */)
|
|
1706
|
+
if (providerTypes[i] == 2 /* Provider.Multi */)
|
|
1705
1707
|
for (let val of value)
|
|
1706
1708
|
values.push(val);
|
|
1707
1709
|
else
|
|
@@ -1714,7 +1716,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1714
1716
|
for (let addr of providerAddrs)
|
|
1715
1717
|
ensureAddr(state, addr);
|
|
1716
1718
|
state.values[idx] = get(state);
|
|
1717
|
-
return 1 /* Changed */;
|
|
1719
|
+
return 1 /* SlotStatus.Changed */;
|
|
1718
1720
|
},
|
|
1719
1721
|
update(state, tr) {
|
|
1720
1722
|
if (!ensureAll(state, dynamic))
|
|
@@ -1723,7 +1725,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1723
1725
|
if (facet.compare(value, state.values[idx]))
|
|
1724
1726
|
return 0;
|
|
1725
1727
|
state.values[idx] = value;
|
|
1726
|
-
return 1 /* Changed */;
|
|
1728
|
+
return 1 /* SlotStatus.Changed */;
|
|
1727
1729
|
},
|
|
1728
1730
|
reconfigure(state, oldState) {
|
|
1729
1731
|
let depChanged = ensureAll(state, providerAddrs);
|
|
@@ -1738,7 +1740,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
1738
1740
|
return 0;
|
|
1739
1741
|
}
|
|
1740
1742
|
state.values[idx] = value;
|
|
1741
|
-
return 1 /* Changed */;
|
|
1743
|
+
return 1 /* SlotStatus.Changed */;
|
|
1742
1744
|
}
|
|
1743
1745
|
};
|
|
1744
1746
|
}
|
|
@@ -1788,7 +1790,7 @@ class StateField {
|
|
|
1788
1790
|
return {
|
|
1789
1791
|
create: (state) => {
|
|
1790
1792
|
state.values[idx] = this.create(state);
|
|
1791
|
-
return 1 /* Changed */;
|
|
1793
|
+
return 1 /* SlotStatus.Changed */;
|
|
1792
1794
|
},
|
|
1793
1795
|
update: (state, tr) => {
|
|
1794
1796
|
let oldVal = state.values[idx];
|
|
@@ -1796,7 +1798,7 @@ class StateField {
|
|
|
1796
1798
|
if (this.compareF(oldVal, value))
|
|
1797
1799
|
return 0;
|
|
1798
1800
|
state.values[idx] = value;
|
|
1799
|
-
return 1 /* Changed */;
|
|
1801
|
+
return 1 /* SlotStatus.Changed */;
|
|
1800
1802
|
},
|
|
1801
1803
|
reconfigure: (state, oldState) => {
|
|
1802
1804
|
if (oldState.config.address[this.id] != null) {
|
|
@@ -1804,7 +1806,7 @@ class StateField {
|
|
|
1804
1806
|
return 0;
|
|
1805
1807
|
}
|
|
1806
1808
|
state.values[idx] = this.create(state);
|
|
1807
|
-
return 1 /* Changed */;
|
|
1809
|
+
return 1 /* SlotStatus.Changed */;
|
|
1808
1810
|
}
|
|
1809
1811
|
};
|
|
1810
1812
|
}
|
|
@@ -1913,7 +1915,7 @@ class Configuration {
|
|
|
1913
1915
|
this.facets = facets;
|
|
1914
1916
|
this.statusTemplate = [];
|
|
1915
1917
|
while (this.statusTemplate.length < dynamicSlots.length)
|
|
1916
|
-
this.statusTemplate.push(0 /* Unresolved */);
|
|
1918
|
+
this.statusTemplate.push(0 /* SlotStatus.Unresolved */);
|
|
1917
1919
|
}
|
|
1918
1920
|
staticFacet(facet) {
|
|
1919
1921
|
let addr = this.address[facet.id];
|
|
@@ -1940,7 +1942,7 @@ class Configuration {
|
|
|
1940
1942
|
for (let id in facets) {
|
|
1941
1943
|
let providers = facets[id], facet = providers[0].facet;
|
|
1942
1944
|
let oldProviders = oldFacets && oldFacets[id] || [];
|
|
1943
|
-
if (providers.every(p => p.type == 0 /* Static */)) {
|
|
1945
|
+
if (providers.every(p => p.type == 0 /* Provider.Static */)) {
|
|
1944
1946
|
address[facet.id] = (staticValues.length << 1) | 1;
|
|
1945
1947
|
if (sameArray(oldProviders, providers)) {
|
|
1946
1948
|
staticValues.push(oldState.facet(facet));
|
|
@@ -1952,7 +1954,7 @@ class Configuration {
|
|
|
1952
1954
|
}
|
|
1953
1955
|
else {
|
|
1954
1956
|
for (let p of providers) {
|
|
1955
|
-
if (p.type == 0 /* Static */) {
|
|
1957
|
+
if (p.type == 0 /* Provider.Static */) {
|
|
1956
1958
|
address[p.id] = (staticValues.length << 1) | 1;
|
|
1957
1959
|
staticValues.push(p.value);
|
|
1958
1960
|
}
|
|
@@ -2020,16 +2022,16 @@ function flatten(extension, compartments, newCompartments) {
|
|
|
2020
2022
|
}
|
|
2021
2023
|
function ensureAddr(state, addr) {
|
|
2022
2024
|
if (addr & 1)
|
|
2023
|
-
return 2 /* Computed */;
|
|
2025
|
+
return 2 /* SlotStatus.Computed */;
|
|
2024
2026
|
let idx = addr >> 1;
|
|
2025
2027
|
let status = state.status[idx];
|
|
2026
|
-
if (status == 4 /* Computing */)
|
|
2028
|
+
if (status == 4 /* SlotStatus.Computing */)
|
|
2027
2029
|
throw new Error("Cyclic dependency between fields and/or facets");
|
|
2028
|
-
if (status & 2 /* Computed */)
|
|
2030
|
+
if (status & 2 /* SlotStatus.Computed */)
|
|
2029
2031
|
return status;
|
|
2030
|
-
state.status[idx] = 4 /* Computing */;
|
|
2032
|
+
state.status[idx] = 4 /* SlotStatus.Computing */;
|
|
2031
2033
|
let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);
|
|
2032
|
-
return state.status[idx] = 2 /* Computed */ | changed;
|
|
2034
|
+
return state.status[idx] = 2 /* SlotStatus.Computed */ | changed;
|
|
2033
2035
|
}
|
|
2034
2036
|
function getAddr(state, addr) {
|
|
2035
2037
|
return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];
|
|
@@ -2466,7 +2468,7 @@ function extendTransaction(tr) {
|
|
|
2466
2468
|
for (let i = extenders.length - 1; i >= 0; i--) {
|
|
2467
2469
|
let extension = extenders[i](tr);
|
|
2468
2470
|
if (extension && Object.keys(extension).length)
|
|
2469
|
-
spec = mergeTransaction(
|
|
2471
|
+
spec = mergeTransaction(spec, resolveTransactionInner(state, extension, tr.changes.newLength), true);
|
|
2470
2472
|
}
|
|
2471
2473
|
return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);
|
|
2472
2474
|
}
|
|
@@ -2804,6 +2806,18 @@ class EditorState {
|
|
|
2804
2806
|
/**
|
|
2805
2807
|
Find the values for a given language data field, provided by the
|
|
2806
2808
|
the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
|
|
2809
|
+
|
|
2810
|
+
Examples of language data fields are...
|
|
2811
|
+
|
|
2812
|
+
- [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
|
|
2813
|
+
comment syntax.
|
|
2814
|
+
- [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
|
|
2815
|
+
for providing language-specific completion sources.
|
|
2816
|
+
- [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
|
|
2817
|
+
characters that should be considered part of words in this
|
|
2818
|
+
language.
|
|
2819
|
+
- [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
|
|
2820
|
+
bracket closing behavior.
|
|
2807
2821
|
*/
|
|
2808
2822
|
languageDataAt(name, pos, side = -1) {
|
|
2809
2823
|
let values = [];
|
|
@@ -3075,7 +3089,7 @@ class Chunk {
|
|
|
3075
3089
|
}
|
|
3076
3090
|
}
|
|
3077
3091
|
between(offset, from, to, f) {
|
|
3078
|
-
for (let i = this.findIndex(from, -1000000000 /* Far */, true), e = this.findIndex(to, 1000000000 /* Far */, false, i); i < e; i++)
|
|
3092
|
+
for (let i = this.findIndex(from, -1000000000 /* C.Far */, true), e = this.findIndex(to, 1000000000 /* C.Far */, false, i); i < e; i++)
|
|
3079
3093
|
if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)
|
|
3080
3094
|
return false;
|
|
3081
3095
|
}
|
|
@@ -3308,7 +3322,7 @@ class RangeSet {
|
|
|
3308
3322
|
*/
|
|
3309
3323
|
static eq(oldSets, newSets, from = 0, to) {
|
|
3310
3324
|
if (to == null)
|
|
3311
|
-
to = 1000000000 /* Far
|
|
3325
|
+
to = 1000000000 /* C.Far */ - 1;
|
|
3312
3326
|
let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
|
|
3313
3327
|
let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
|
|
3314
3328
|
if (a.length != b.length)
|
|
@@ -3403,8 +3417,8 @@ class RangeSetBuilder {
|
|
|
3403
3417
|
this.chunkPos = [];
|
|
3404
3418
|
this.chunkStart = -1;
|
|
3405
3419
|
this.last = null;
|
|
3406
|
-
this.lastFrom = -1000000000 /* Far */;
|
|
3407
|
-
this.lastTo = -1000000000 /* Far */;
|
|
3420
|
+
this.lastFrom = -1000000000 /* C.Far */;
|
|
3421
|
+
this.lastTo = -1000000000 /* C.Far */;
|
|
3408
3422
|
this.from = [];
|
|
3409
3423
|
this.to = [];
|
|
3410
3424
|
this.value = [];
|
|
@@ -3441,7 +3455,7 @@ class RangeSetBuilder {
|
|
|
3441
3455
|
throw new Error("Ranges must be added sorted by `from` position and `startSide`");
|
|
3442
3456
|
if (diff < 0)
|
|
3443
3457
|
return false;
|
|
3444
|
-
if (this.from.length == 250 /* ChunkSize */)
|
|
3458
|
+
if (this.from.length == 250 /* C.ChunkSize */)
|
|
3445
3459
|
this.finishChunk(true);
|
|
3446
3460
|
if (this.chunkStart < 0)
|
|
3447
3461
|
this.chunkStart = from;
|
|
@@ -3515,7 +3529,7 @@ class LayerCursor {
|
|
|
3515
3529
|
}
|
|
3516
3530
|
get startSide() { return this.value ? this.value.startSide : 0; }
|
|
3517
3531
|
get endSide() { return this.value ? this.value.endSide : 0; }
|
|
3518
|
-
goto(pos, side = -1000000000 /* Far */) {
|
|
3532
|
+
goto(pos, side = -1000000000 /* C.Far */) {
|
|
3519
3533
|
this.chunkIndex = this.rangeIndex = 0;
|
|
3520
3534
|
this.gotoInner(pos, side, false);
|
|
3521
3535
|
return this;
|
|
@@ -3544,7 +3558,7 @@ class LayerCursor {
|
|
|
3544
3558
|
next() {
|
|
3545
3559
|
for (;;) {
|
|
3546
3560
|
if (this.chunkIndex == this.layer.chunk.length) {
|
|
3547
|
-
this.from = this.to = 1000000000 /* Far */;
|
|
3561
|
+
this.from = this.to = 1000000000 /* C.Far */;
|
|
3548
3562
|
this.value = null;
|
|
3549
3563
|
break;
|
|
3550
3564
|
}
|
|
@@ -3598,7 +3612,7 @@ class HeapCursor {
|
|
|
3598
3612
|
return heap.length == 1 ? heap[0] : new HeapCursor(heap);
|
|
3599
3613
|
}
|
|
3600
3614
|
get startSide() { return this.value ? this.value.startSide : 0; }
|
|
3601
|
-
goto(pos, side = -1000000000 /* Far */) {
|
|
3615
|
+
goto(pos, side = -1000000000 /* C.Far */) {
|
|
3602
3616
|
for (let cur of this.heap)
|
|
3603
3617
|
cur.goto(pos, side);
|
|
3604
3618
|
for (let i = this.heap.length >> 1; i >= 0; i--)
|
|
@@ -3616,7 +3630,7 @@ class HeapCursor {
|
|
|
3616
3630
|
}
|
|
3617
3631
|
next() {
|
|
3618
3632
|
if (this.heap.length == 0) {
|
|
3619
|
-
this.from = this.to = 1000000000 /* Far */;
|
|
3633
|
+
this.from = this.to = 1000000000 /* C.Far */;
|
|
3620
3634
|
this.value = null;
|
|
3621
3635
|
this.rank = -1;
|
|
3622
3636
|
}
|
|
@@ -3660,12 +3674,12 @@ class SpanCursor {
|
|
|
3660
3674
|
this.point = null;
|
|
3661
3675
|
this.pointFrom = 0;
|
|
3662
3676
|
this.pointRank = 0;
|
|
3663
|
-
this.to = -1000000000 /* Far */;
|
|
3677
|
+
this.to = -1000000000 /* C.Far */;
|
|
3664
3678
|
this.endSide = 0;
|
|
3665
3679
|
this.openStart = -1;
|
|
3666
3680
|
this.cursor = HeapCursor.from(sets, skip, minPoint);
|
|
3667
3681
|
}
|
|
3668
|
-
goto(pos, side = -1000000000 /* Far */) {
|
|
3682
|
+
goto(pos, side = -1000000000 /* C.Far */) {
|
|
3669
3683
|
this.cursor.goto(pos, side);
|
|
3670
3684
|
this.active.length = this.activeTo.length = this.activeRank.length = 0;
|
|
3671
3685
|
this.minActive = -1;
|
|
@@ -3716,7 +3730,7 @@ class SpanCursor {
|
|
|
3716
3730
|
remove(trackOpen, a);
|
|
3717
3731
|
}
|
|
3718
3732
|
else if (!this.cursor.value) {
|
|
3719
|
-
this.to = this.endSide = 1000000000 /* Far */;
|
|
3733
|
+
this.to = this.endSide = 1000000000 /* C.Far */;
|
|
3720
3734
|
break;
|
|
3721
3735
|
}
|
|
3722
3736
|
else if (this.cursor.from > from) {
|
|
@@ -3821,7 +3835,7 @@ function insert(array, index, value) {
|
|
|
3821
3835
|
array[index] = value;
|
|
3822
3836
|
}
|
|
3823
3837
|
function findMinIndex(value, array) {
|
|
3824
|
-
let found = -1, foundPos = 1000000000 /* Far */;
|
|
3838
|
+
let found = -1, foundPos = 1000000000 /* C.Far */;
|
|
3825
3839
|
for (let i = 0; i < array.length; i++)
|
|
3826
3840
|
if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {
|
|
3827
3841
|
found = i;
|