@codemirror/state 6.7.2 → 6.7.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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## 6.7.3 (2026-09-04)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix an issue where, since the last version, mapping a range set could throw an error about range order.
6
+
1
7
  ## 6.7.2 (2026-08-31)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -3239,7 +3239,7 @@ class RangeSet {
3239
3239
  while (cur.value || i < add.length) {
3240
3240
  if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
3241
3241
  let range = add[i++];
3242
- if (!builder.addInner(range.from, range.to, range.value))
3242
+ if (!builder.addInner(range.from, range.to, range.value, false))
3243
3243
  spill.push(range);
3244
3244
  }
3245
3245
  else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
@@ -3250,7 +3250,7 @@ class RangeSet {
3250
3250
  }
3251
3251
  else {
3252
3252
  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))
3253
+ if (!builder.addInner(cur.from, cur.to, cur.value, false))
3254
3254
  spill.push(Range.create(cur.from, cur.to, cur.value));
3255
3255
  }
3256
3256
  cur.next();
@@ -3270,7 +3270,7 @@ class RangeSet {
3270
3270
  let spill = (from, to, value) => {
3271
3271
  if (!spilled)
3272
3272
  spilled = new RangeSetBuilder();
3273
- spilled.add(from, to, value);
3273
+ spilled.addRange(from, to, value, false);
3274
3274
  };
3275
3275
  for (let i = 0; i < this.chunk.length; i++) {
3276
3276
  let start = this.chunkPos[i], chunk = this.chunk[i];
@@ -3498,16 +3498,20 @@ class RangeSetBuilder {
3498
3498
  Add a range. Ranges should be added in sorted (by `from` and
3499
3499
  `value.startSide`) order.
3500
3500
  */
3501
- add(from, to, value) {
3502
- if (!this.addInner(from, to, value))
3503
- (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);
3501
+ add(from, to, value) { this.addRange(from, to, value, true); }
3502
+ /**
3503
+ @internal
3504
+ */
3505
+ addRange(from, to, value, strict) {
3506
+ if (!this.addInner(from, to, value, strict))
3507
+ (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).addRange(from, to, value, strict);
3504
3508
  }
3505
3509
  /**
3506
3510
  @internal
3507
3511
  */
3508
- addInner(from, to, value) {
3512
+ addInner(from, to, value, strict) {
3509
3513
  let diff = from - this.lastTo || value.startSide - this.last.endSide;
3510
- if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
3514
+ if (strict && diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
3511
3515
  throw new Error("Ranges must be added sorted by `from` position and `startSide`");
3512
3516
  if (diff < 0)
3513
3517
  return false;
package/dist/index.js CHANGED
@@ -3235,7 +3235,7 @@ class RangeSet {
3235
3235
  while (cur.value || i < add.length) {
3236
3236
  if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {
3237
3237
  let range = add[i++];
3238
- if (!builder.addInner(range.from, range.to, range.value))
3238
+ if (!builder.addInner(range.from, range.to, range.value, false))
3239
3239
  spill.push(range);
3240
3240
  }
3241
3241
  else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&
@@ -3246,7 +3246,7 @@ class RangeSet {
3246
3246
  }
3247
3247
  else {
3248
3248
  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))
3249
+ if (!builder.addInner(cur.from, cur.to, cur.value, false))
3250
3250
  spill.push(Range.create(cur.from, cur.to, cur.value));
3251
3251
  }
3252
3252
  cur.next();
@@ -3266,7 +3266,7 @@ class RangeSet {
3266
3266
  let spill = (from, to, value) => {
3267
3267
  if (!spilled)
3268
3268
  spilled = new RangeSetBuilder();
3269
- spilled.add(from, to, value);
3269
+ spilled.addRange(from, to, value, false);
3270
3270
  };
3271
3271
  for (let i = 0; i < this.chunk.length; i++) {
3272
3272
  let start = this.chunkPos[i], chunk = this.chunk[i];
@@ -3494,16 +3494,20 @@ class RangeSetBuilder {
3494
3494
  Add a range. Ranges should be added in sorted (by `from` and
3495
3495
  `value.startSide`) order.
3496
3496
  */
3497
- add(from, to, value) {
3498
- if (!this.addInner(from, to, value))
3499
- (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);
3497
+ add(from, to, value) { this.addRange(from, to, value, true); }
3498
+ /**
3499
+ @internal
3500
+ */
3501
+ addRange(from, to, value, strict) {
3502
+ if (!this.addInner(from, to, value, strict))
3503
+ (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).addRange(from, to, value, strict);
3500
3504
  }
3501
3505
  /**
3502
3506
  @internal
3503
3507
  */
3504
- addInner(from, to, value) {
3508
+ addInner(from, to, value, strict) {
3505
3509
  let diff = from - this.lastTo || value.startSide - this.last.endSide;
3506
- if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
3510
+ if (strict && diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)
3507
3511
  throw new Error("Ranges must be added sorted by `from` position and `startSide`");
3508
3512
  if (diff < 0)
3509
3513
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/state",
3
- "version": "6.7.2",
3
+ "version": "6.7.3",
4
4
  "description": "Editor state data structures for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",