@codemirror/state 6.7.2 → 6.7.4
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 +12 -0
- package/dist/index.cjs +18 -12
- package/dist/index.js +18 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 6.7.4 (2026-09-04)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix the sorting of point ranges when mapping collapses points to the same position.
|
|
6
|
+
|
|
7
|
+
## 6.7.3 (2026-09-04)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Fix an issue where, since the last version, mapping a range set could throw an error about range order.
|
|
12
|
+
|
|
1
13
|
## 6.7.2 (2026-08-31)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -3141,13 +3141,15 @@ class Chunk {
|
|
|
3141
3141
|
}
|
|
3142
3142
|
else {
|
|
3143
3143
|
if (newFrom == newTo) { // Try to reorder points to fit in here
|
|
3144
|
-
for (let i = value.length
|
|
3145
|
-
if ((newFrom - to[i - 1] || val.startSide - value[i - 1].endSide)
|
|
3144
|
+
for (let i = value.length; i > 0; i--) {
|
|
3145
|
+
if ((newFrom - (to[i - 1] + newPos) || val.startSide - value[i - 1].endSide) >= 0) {
|
|
3146
3146
|
value.splice(i, 0, val);
|
|
3147
|
-
from.splice(i, 0, newFrom);
|
|
3148
|
-
to.splice(i, 0, newTo);
|
|
3147
|
+
from.splice(i, 0, newFrom - newPos);
|
|
3148
|
+
to.splice(i, 0, newTo - newPos);
|
|
3149
3149
|
continue iter;
|
|
3150
3150
|
}
|
|
3151
|
+
if ((newFrom - (from[i - 1] + newPos) || val.endSide - value[i - 1].startSide) > 0)
|
|
3152
|
+
break;
|
|
3151
3153
|
}
|
|
3152
3154
|
}
|
|
3153
3155
|
// Otherwise, spill into a new layer
|
|
@@ -3239,7 +3241,7 @@ class RangeSet {
|
|
|
3239
3241
|
while (cur.value || i < add.length) {
|
|
3240
3242
|
if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
|
|
3241
3243
|
let range = add[i++];
|
|
3242
|
-
if (!builder.addInner(range.from, range.to, range.value))
|
|
3244
|
+
if (!builder.addInner(range.from, range.to, range.value, false))
|
|
3243
3245
|
spill.push(range);
|
|
3244
3246
|
}
|
|
3245
3247
|
else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
|
|
@@ -3250,7 +3252,7 @@ class RangeSet {
|
|
|
3250
3252
|
}
|
|
3251
3253
|
else {
|
|
3252
3254
|
if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
|
|
3253
|
-
if (!builder.addInner(cur.from, cur.to, cur.value))
|
|
3255
|
+
if (!builder.addInner(cur.from, cur.to, cur.value, false))
|
|
3254
3256
|
spill.push(Range.create(cur.from, cur.to, cur.value));
|
|
3255
3257
|
}
|
|
3256
3258
|
cur.next();
|
|
@@ -3270,7 +3272,7 @@ class RangeSet {
|
|
|
3270
3272
|
let spill = (from, to, value) => {
|
|
3271
3273
|
if (!spilled)
|
|
3272
3274
|
spilled = new RangeSetBuilder();
|
|
3273
|
-
spilled.
|
|
3275
|
+
spilled.addRange(from, to, value, false);
|
|
3274
3276
|
};
|
|
3275
3277
|
for (let i = 0; i < this.chunk.length; i++) {
|
|
3276
3278
|
let start = this.chunkPos[i], chunk = this.chunk[i];
|
|
@@ -3498,16 +3500,20 @@ class RangeSetBuilder {
|
|
|
3498
3500
|
Add a range. Ranges should be added in sorted (by `from` and
|
|
3499
3501
|
`value.startSide`) order.
|
|
3500
3502
|
*/
|
|
3501
|
-
add(from, to, value) {
|
|
3502
|
-
|
|
3503
|
-
|
|
3503
|
+
add(from, to, value) { this.addRange(from, to, value, true); }
|
|
3504
|
+
/**
|
|
3505
|
+
@internal
|
|
3506
|
+
*/
|
|
3507
|
+
addRange(from, to, value, strict) {
|
|
3508
|
+
if (!this.addInner(from, to, value, strict))
|
|
3509
|
+
(this.nextLayer || (this.nextLayer = new RangeSetBuilder)).addRange(from, to, value, strict);
|
|
3504
3510
|
}
|
|
3505
3511
|
/**
|
|
3506
3512
|
@internal
|
|
3507
3513
|
*/
|
|
3508
|
-
addInner(from, to, value) {
|
|
3514
|
+
addInner(from, to, value, strict) {
|
|
3509
3515
|
let diff = from - this.lastTo || value.startSide - this.last.endSide;
|
|
3510
|
-
if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
|
|
3516
|
+
if (strict && diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
|
|
3511
3517
|
throw new Error("Ranges must be added sorted by `from` position and `startSide`");
|
|
3512
3518
|
if (diff < 0)
|
|
3513
3519
|
return false;
|
package/dist/index.js
CHANGED
|
@@ -3137,13 +3137,15 @@ class Chunk {
|
|
|
3137
3137
|
}
|
|
3138
3138
|
else {
|
|
3139
3139
|
if (newFrom == newTo) { // Try to reorder points to fit in here
|
|
3140
|
-
for (let i = value.length
|
|
3141
|
-
if ((newFrom - to[i - 1] || val.startSide - value[i - 1].endSide)
|
|
3140
|
+
for (let i = value.length; i > 0; i--) {
|
|
3141
|
+
if ((newFrom - (to[i - 1] + newPos) || val.startSide - value[i - 1].endSide) >= 0) {
|
|
3142
3142
|
value.splice(i, 0, val);
|
|
3143
|
-
from.splice(i, 0, newFrom);
|
|
3144
|
-
to.splice(i, 0, newTo);
|
|
3143
|
+
from.splice(i, 0, newFrom - newPos);
|
|
3144
|
+
to.splice(i, 0, newTo - newPos);
|
|
3145
3145
|
continue iter;
|
|
3146
3146
|
}
|
|
3147
|
+
if ((newFrom - (from[i - 1] + newPos) || val.endSide - value[i - 1].startSide) > 0)
|
|
3148
|
+
break;
|
|
3147
3149
|
}
|
|
3148
3150
|
}
|
|
3149
3151
|
// Otherwise, spill into a new layer
|
|
@@ -3235,7 +3237,7 @@ class RangeSet {
|
|
|
3235
3237
|
while (cur.value || i < add.length) {
|
|
3236
3238
|
if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
|
|
3237
3239
|
let range = add[i++];
|
|
3238
|
-
if (!builder.addInner(range.from, range.to, range.value))
|
|
3240
|
+
if (!builder.addInner(range.from, range.to, range.value, false))
|
|
3239
3241
|
spill.push(range);
|
|
3240
3242
|
}
|
|
3241
3243
|
else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
|
|
@@ -3246,7 +3248,7 @@ class RangeSet {
|
|
|
3246
3248
|
}
|
|
3247
3249
|
else {
|
|
3248
3250
|
if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
|
|
3249
|
-
if (!builder.addInner(cur.from, cur.to, cur.value))
|
|
3251
|
+
if (!builder.addInner(cur.from, cur.to, cur.value, false))
|
|
3250
3252
|
spill.push(Range.create(cur.from, cur.to, cur.value));
|
|
3251
3253
|
}
|
|
3252
3254
|
cur.next();
|
|
@@ -3266,7 +3268,7 @@ class RangeSet {
|
|
|
3266
3268
|
let spill = (from, to, value) => {
|
|
3267
3269
|
if (!spilled)
|
|
3268
3270
|
spilled = new RangeSetBuilder();
|
|
3269
|
-
spilled.
|
|
3271
|
+
spilled.addRange(from, to, value, false);
|
|
3270
3272
|
};
|
|
3271
3273
|
for (let i = 0; i < this.chunk.length; i++) {
|
|
3272
3274
|
let start = this.chunkPos[i], chunk = this.chunk[i];
|
|
@@ -3494,16 +3496,20 @@ class RangeSetBuilder {
|
|
|
3494
3496
|
Add a range. Ranges should be added in sorted (by `from` and
|
|
3495
3497
|
`value.startSide`) order.
|
|
3496
3498
|
*/
|
|
3497
|
-
add(from, to, value) {
|
|
3498
|
-
|
|
3499
|
-
|
|
3499
|
+
add(from, to, value) { this.addRange(from, to, value, true); }
|
|
3500
|
+
/**
|
|
3501
|
+
@internal
|
|
3502
|
+
*/
|
|
3503
|
+
addRange(from, to, value, strict) {
|
|
3504
|
+
if (!this.addInner(from, to, value, strict))
|
|
3505
|
+
(this.nextLayer || (this.nextLayer = new RangeSetBuilder)).addRange(from, to, value, strict);
|
|
3500
3506
|
}
|
|
3501
3507
|
/**
|
|
3502
3508
|
@internal
|
|
3503
3509
|
*/
|
|
3504
|
-
addInner(from, to, value) {
|
|
3510
|
+
addInner(from, to, value, strict) {
|
|
3505
3511
|
let diff = from - this.lastTo || value.startSide - this.last.endSide;
|
|
3506
|
-
if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
|
|
3512
|
+
if (strict && diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
|
|
3507
3513
|
throw new Error("Ranges must be added sorted by `from` position and `startSide`");
|
|
3508
3514
|
if (diff < 0)
|
|
3509
3515
|
return false;
|