@codemirror/view 0.19.11 → 0.19.12

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,11 @@
1
+ ## 0.19.12 (2021-11-04)
2
+
3
+ ### Bug fixes
4
+
5
+ Make sure the workaround for the lost virtual keyboard on Chrome Android also works on slower phones. Slight style change in beforeinput handler
6
+
7
+ Avoid failure cases in viewport-based rendering of very long lines.
8
+
1
9
  ## 0.19.11 (2021-11-03)
2
10
 
3
11
  ### Breaking changes
package/dist/index.cjs CHANGED
@@ -321,25 +321,30 @@ class ContentView {
321
321
  sync(track) {
322
322
  var _a;
323
323
  if (this.dirty & 2 /* Node */) {
324
- let parent = this.dom, pos = null;
324
+ let parent = this.dom;
325
+ let pos = parent.firstChild;
325
326
  for (let child of this.children) {
326
327
  if (child.dirty) {
327
- let next = pos ? pos.nextSibling : parent.firstChild;
328
- if (!child.dom && next && !((_a = ContentView.get(next)) === null || _a === void 0 ? void 0 : _a.parent))
329
- child.reuseDOM(next);
328
+ if (!child.dom && pos && !((_a = ContentView.get(pos)) === null || _a === void 0 ? void 0 : _a.parent))
329
+ child.reuseDOM(pos);
330
330
  child.sync(track);
331
331
  child.dirty = 0 /* Not */;
332
332
  }
333
- if (track && track.node == parent && pos != child.dom)
333
+ if (track && !track.written && track.node == parent && pos != child.dom)
334
334
  track.written = true;
335
- syncNodeInto(parent, pos, child.dom);
336
- pos = child.dom;
335
+ if (child.dom.parentNode == parent) {
336
+ while (pos && pos != child.dom)
337
+ pos = rm(pos);
338
+ pos = child.dom.nextSibling;
339
+ }
340
+ else {
341
+ parent.insertBefore(child.dom, pos);
342
+ }
337
343
  }
338
- let next = pos ? pos.nextSibling : parent.firstChild;
339
- if (next && track && track.node == parent)
344
+ if (pos && track && track.node == parent)
340
345
  track.written = true;
341
- while (next)
342
- next = rm(next);
346
+ while (pos)
347
+ pos = rm(pos);
343
348
  }
344
349
  else if (this.dirty & 1 /* Child */) {
345
350
  for (let child of this.children)
@@ -479,14 +484,6 @@ function rm(dom) {
479
484
  dom.parentNode.removeChild(dom);
480
485
  return next;
481
486
  }
482
- function syncNodeInto(parent, after, dom) {
483
- let next = after ? after.nextSibling : parent.firstChild;
484
- if (dom.parentNode == parent)
485
- while (next != dom)
486
- next = rm(next);
487
- else
488
- parent.insertBefore(dom, next);
489
- }
490
487
  class ChildCursor {
491
488
  constructor(children, pos, i) {
492
489
  this.children = children;
@@ -3735,17 +3732,19 @@ handlers.beforeinput = (view, event) => {
3735
3732
  let pending;
3736
3733
  if (browser.chrome && browser.android && (pending = PendingKeys.find(key => key.inputType == event.inputType))) {
3737
3734
  view.inputState.setPendingKey(view, pending);
3738
- let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;
3739
- setTimeout(() => {
3740
- var _a;
3741
- // Backspacing near uneditable nodes on Chrome Android sometimes
3742
- // closes the virtual keyboard. This tries to crudely detect
3743
- // that and refocus to get it back.
3744
- if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
3745
- view.contentDOM.blur();
3746
- view.focus();
3747
- }
3748
- }, 50);
3735
+ if (pending.key == "Backspace" || pending.key == "Delete") {
3736
+ let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;
3737
+ setTimeout(() => {
3738
+ var _a;
3739
+ // Backspacing near uneditable nodes on Chrome Android sometimes
3740
+ // closes the virtual keyboard. This tries to crudely detect
3741
+ // that and refocus to get it back.
3742
+ if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
3743
+ view.contentDOM.blur();
3744
+ view.focus();
3745
+ }
3746
+ }, 100);
3747
+ }
3749
3748
  }
3750
3749
  };
3751
3750
 
@@ -4533,7 +4532,7 @@ class ViewState {
4533
4532
  viewport = this.getViewport(0, scrollTarget);
4534
4533
  this.viewport = viewport;
4535
4534
  this.updateForViewport();
4536
- if (this.lineGaps.length || this.viewport.to - this.viewport.from > 15000 /* MinViewPort */)
4535
+ if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
4537
4536
  this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
4538
4537
  update.flags |= this.computeVisibleRanges();
4539
4538
  if (scrollTarget)
@@ -4593,7 +4592,7 @@ class ViewState {
4593
4592
  this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to))
4594
4593
  this.viewport = this.getViewport(bias, this.scrollTarget);
4595
4594
  this.updateForViewport();
4596
- if (this.lineGaps.length || this.viewport.to - this.viewport.from > 15000 /* MinViewPort */)
4595
+ if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
4597
4596
  this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
4598
4597
  result |= this.computeVisibleRanges();
4599
4598
  if (this.mustEnforceCursorAssoc) {
@@ -4668,52 +4667,50 @@ class ViewState {
4668
4667
  if (this.heightOracle.direction != exports.Direction.LTR)
4669
4668
  return gaps;
4670
4669
  this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.state.doc, 0, 0, line => {
4671
- if (line.length < 10000 /* Margin */)
4670
+ if (line.length < 4000 /* DoubleMargin */)
4672
4671
  return;
4673
4672
  let structure = lineStructure(line.from, line.to, this.state);
4674
- if (structure.total < 10000 /* Margin */)
4673
+ if (structure.total < 4000 /* DoubleMargin */)
4675
4674
  return;
4676
4675
  let viewFrom, viewTo;
4677
4676
  if (this.heightOracle.lineWrapping) {
4678
- if (line.from != this.viewport.from)
4679
- viewFrom = line.from;
4680
- else
4681
- viewFrom = findPosition(structure, (this.visibleTop - line.top) / line.height);
4682
- if (line.to != this.viewport.to)
4683
- viewTo = line.to;
4684
- else
4685
- viewTo = findPosition(structure, (this.visibleBottom - line.top) / line.height);
4677
+ let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
4678
+ viewFrom = findPosition(structure, (this.visibleTop - line.top - marginHeight) / line.height);
4679
+ viewTo = findPosition(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
4686
4680
  }
4687
4681
  else {
4688
4682
  let totalWidth = structure.total * this.heightOracle.charWidth;
4689
- viewFrom = findPosition(structure, this.pixelViewport.left / totalWidth);
4690
- viewTo = findPosition(structure, this.pixelViewport.right / totalWidth);
4683
+ let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
4684
+ viewFrom = findPosition(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
4685
+ viewTo = findPosition(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
4691
4686
  }
4687
+ let outside = [];
4688
+ if (viewFrom > line.from)
4689
+ outside.push({ from: line.from, to: viewFrom });
4690
+ if (viewTo < line.to)
4691
+ outside.push({ from: viewTo, to: line.to });
4692
4692
  let sel = this.state.selection.main;
4693
- // Make sure the gap doesn't cover a selection end
4694
- if (sel.from <= viewFrom && sel.to >= line.from)
4695
- viewFrom = sel.from;
4696
- if (sel.from <= line.to && sel.to >= viewTo)
4697
- viewTo = sel.to;
4698
- let gapTo = viewFrom - 10000 /* Margin */, gapFrom = viewTo + 10000 /* Margin */;
4699
- if (gapTo > line.from + 5000 /* HalfMargin */)
4700
- gaps.push(find(current, gap => gap.from == line.from && gap.to > gapTo - 5000 /* HalfMargin */ && gap.to < gapTo + 5000 /* HalfMargin */) ||
4701
- new LineGap(line.from, gapTo, this.gapSize(line, gapTo, true, structure)));
4702
- if (gapFrom < line.to - 5000 /* HalfMargin */)
4703
- gaps.push(find(current, gap => gap.to == line.to && gap.from > gapFrom - 5000 /* HalfMargin */ &&
4704
- gap.from < gapFrom + 5000 /* HalfMargin */) ||
4705
- new LineGap(gapFrom, line.to, this.gapSize(line, gapFrom, false, structure)));
4693
+ // Make sure the gaps don't cover a selection end
4694
+ if (sel.from >= line.from && sel.from <= line.to)
4695
+ cutRange(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
4696
+ if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
4697
+ cutRange(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
4698
+ for (let { from, to } of outside)
4699
+ if (to - from > 1000 /* HalfMargin */) {
4700
+ gaps.push(find(current, gap => gap.from >= line.from && gap.to <= line.to &&
4701
+ Math.abs(gap.from - from) < 1000 /* HalfMargin */ && Math.abs(gap.to - to) < 1000 /* HalfMargin */) ||
4702
+ new LineGap(from, to, this.gapSize(line, from, to, structure)));
4703
+ }
4706
4704
  });
4707
4705
  return gaps;
4708
4706
  }
4709
- gapSize(line, pos, start, structure) {
4707
+ gapSize(line, from, to, structure) {
4708
+ let fraction = findFraction(structure, to) - findFraction(structure, from);
4710
4709
  if (this.heightOracle.lineWrapping) {
4711
- let height = line.height * findFraction(structure, pos);
4712
- return start ? height : line.height - height;
4710
+ return line.height * fraction;
4713
4711
  }
4714
4712
  else {
4715
- let ratio = findFraction(structure, pos);
4716
- return structure.total * this.heightOracle.charWidth * (start ? ratio : 1 - ratio);
4713
+ return structure.total * this.heightOracle.charWidth * fraction;
4717
4714
  }
4718
4715
  }
4719
4716
  updateLineGaps(gaps) {
@@ -4807,6 +4804,20 @@ function findFraction(structure, pos) {
4807
4804
  }
4808
4805
  return counted / structure.total;
4809
4806
  }
4807
+ function cutRange(ranges, from, to) {
4808
+ for (let i = 0; i < ranges.length; i++) {
4809
+ let r = ranges[i];
4810
+ if (r.from < to && r.to > from) {
4811
+ let pieces = [];
4812
+ if (r.from < from)
4813
+ pieces.push({ from: r.from, to: from });
4814
+ if (r.to > to)
4815
+ pieces.push({ from: to, to: r.to });
4816
+ ranges.splice(i, 1, ...pieces);
4817
+ i += pieces.length - 1;
4818
+ }
4819
+ }
4820
+ }
4810
4821
  function find(array, f) {
4811
4822
  for (let val of array)
4812
4823
  if (f(val))
@@ -6271,7 +6282,7 @@ class EditorView {
6271
6282
  target editors with a dark or light theme.
6272
6283
  */
6273
6284
  static baseTheme(spec) {
6274
- return state.Prec.fallback(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
6285
+ return state.Prec.lowest(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
6275
6286
  }
6276
6287
  }
6277
6288
  /**
@@ -6713,7 +6724,7 @@ const themeSpec = {
6713
6724
  };
6714
6725
  if (CanHidePrimary)
6715
6726
  themeSpec[".cm-line"].caretColor = "transparent !important";
6716
- const hideNativeSelection = state.Prec.override(EditorView.theme(themeSpec));
6727
+ const hideNativeSelection = state.Prec.highest(EditorView.theme(themeSpec));
6717
6728
  function getBase(view) {
6718
6729
  let rect = view.scrollDOM.getBoundingClientRect();
6719
6730
  let left = view.textDirection == exports.Direction.LTR ? rect.left : rect.right - view.scrollDOM.clientWidth;
package/dist/index.js CHANGED
@@ -318,25 +318,30 @@ class ContentView {
318
318
  sync(track) {
319
319
  var _a;
320
320
  if (this.dirty & 2 /* Node */) {
321
- let parent = this.dom, pos = null;
321
+ let parent = this.dom;
322
+ let pos = parent.firstChild;
322
323
  for (let child of this.children) {
323
324
  if (child.dirty) {
324
- let next = pos ? pos.nextSibling : parent.firstChild;
325
- if (!child.dom && next && !((_a = ContentView.get(next)) === null || _a === void 0 ? void 0 : _a.parent))
326
- child.reuseDOM(next);
325
+ if (!child.dom && pos && !((_a = ContentView.get(pos)) === null || _a === void 0 ? void 0 : _a.parent))
326
+ child.reuseDOM(pos);
327
327
  child.sync(track);
328
328
  child.dirty = 0 /* Not */;
329
329
  }
330
- if (track && track.node == parent && pos != child.dom)
330
+ if (track && !track.written && track.node == parent && pos != child.dom)
331
331
  track.written = true;
332
- syncNodeInto(parent, pos, child.dom);
333
- pos = child.dom;
332
+ if (child.dom.parentNode == parent) {
333
+ while (pos && pos != child.dom)
334
+ pos = rm(pos);
335
+ pos = child.dom.nextSibling;
336
+ }
337
+ else {
338
+ parent.insertBefore(child.dom, pos);
339
+ }
334
340
  }
335
- let next = pos ? pos.nextSibling : parent.firstChild;
336
- if (next && track && track.node == parent)
341
+ if (pos && track && track.node == parent)
337
342
  track.written = true;
338
- while (next)
339
- next = rm(next);
343
+ while (pos)
344
+ pos = rm(pos);
340
345
  }
341
346
  else if (this.dirty & 1 /* Child */) {
342
347
  for (let child of this.children)
@@ -476,14 +481,6 @@ function rm(dom) {
476
481
  dom.parentNode.removeChild(dom);
477
482
  return next;
478
483
  }
479
- function syncNodeInto(parent, after, dom) {
480
- let next = after ? after.nextSibling : parent.firstChild;
481
- if (dom.parentNode == parent)
482
- while (next != dom)
483
- next = rm(next);
484
- else
485
- parent.insertBefore(dom, next);
486
- }
487
484
  class ChildCursor {
488
485
  constructor(children, pos, i) {
489
486
  this.children = children;
@@ -3730,17 +3727,19 @@ handlers.beforeinput = (view, event) => {
3730
3727
  let pending;
3731
3728
  if (browser.chrome && browser.android && (pending = PendingKeys.find(key => key.inputType == event.inputType))) {
3732
3729
  view.inputState.setPendingKey(view, pending);
3733
- let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;
3734
- setTimeout(() => {
3735
- var _a;
3736
- // Backspacing near uneditable nodes on Chrome Android sometimes
3737
- // closes the virtual keyboard. This tries to crudely detect
3738
- // that and refocus to get it back.
3739
- if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
3740
- view.contentDOM.blur();
3741
- view.focus();
3742
- }
3743
- }, 50);
3730
+ if (pending.key == "Backspace" || pending.key == "Delete") {
3731
+ let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;
3732
+ setTimeout(() => {
3733
+ var _a;
3734
+ // Backspacing near uneditable nodes on Chrome Android sometimes
3735
+ // closes the virtual keyboard. This tries to crudely detect
3736
+ // that and refocus to get it back.
3737
+ if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {
3738
+ view.contentDOM.blur();
3739
+ view.focus();
3740
+ }
3741
+ }, 100);
3742
+ }
3744
3743
  }
3745
3744
  };
3746
3745
 
@@ -4527,7 +4526,7 @@ class ViewState {
4527
4526
  viewport = this.getViewport(0, scrollTarget);
4528
4527
  this.viewport = viewport;
4529
4528
  this.updateForViewport();
4530
- if (this.lineGaps.length || this.viewport.to - this.viewport.from > 15000 /* MinViewPort */)
4529
+ if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
4531
4530
  this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));
4532
4531
  update.flags |= this.computeVisibleRanges();
4533
4532
  if (scrollTarget)
@@ -4587,7 +4586,7 @@ class ViewState {
4587
4586
  this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to))
4588
4587
  this.viewport = this.getViewport(bias, this.scrollTarget);
4589
4588
  this.updateForViewport();
4590
- if (this.lineGaps.length || this.viewport.to - this.viewport.from > 15000 /* MinViewPort */)
4589
+ if (this.lineGaps.length || this.viewport.to - this.viewport.from > 4000 /* DoubleMargin */)
4591
4590
  this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps));
4592
4591
  result |= this.computeVisibleRanges();
4593
4592
  if (this.mustEnforceCursorAssoc) {
@@ -4662,52 +4661,50 @@ class ViewState {
4662
4661
  if (this.heightOracle.direction != Direction.LTR)
4663
4662
  return gaps;
4664
4663
  this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.state.doc, 0, 0, line => {
4665
- if (line.length < 10000 /* Margin */)
4664
+ if (line.length < 4000 /* DoubleMargin */)
4666
4665
  return;
4667
4666
  let structure = lineStructure(line.from, line.to, this.state);
4668
- if (structure.total < 10000 /* Margin */)
4667
+ if (structure.total < 4000 /* DoubleMargin */)
4669
4668
  return;
4670
4669
  let viewFrom, viewTo;
4671
4670
  if (this.heightOracle.lineWrapping) {
4672
- if (line.from != this.viewport.from)
4673
- viewFrom = line.from;
4674
- else
4675
- viewFrom = findPosition(structure, (this.visibleTop - line.top) / line.height);
4676
- if (line.to != this.viewport.to)
4677
- viewTo = line.to;
4678
- else
4679
- viewTo = findPosition(structure, (this.visibleBottom - line.top) / line.height);
4671
+ let marginHeight = (2000 /* Margin */ / this.heightOracle.lineLength) * this.heightOracle.lineHeight;
4672
+ viewFrom = findPosition(structure, (this.visibleTop - line.top - marginHeight) / line.height);
4673
+ viewTo = findPosition(structure, (this.visibleBottom - line.top + marginHeight) / line.height);
4680
4674
  }
4681
4675
  else {
4682
4676
  let totalWidth = structure.total * this.heightOracle.charWidth;
4683
- viewFrom = findPosition(structure, this.pixelViewport.left / totalWidth);
4684
- viewTo = findPosition(structure, this.pixelViewport.right / totalWidth);
4677
+ let marginWidth = 2000 /* Margin */ * this.heightOracle.charWidth;
4678
+ viewFrom = findPosition(structure, (this.pixelViewport.left - marginWidth) / totalWidth);
4679
+ viewTo = findPosition(structure, (this.pixelViewport.right + marginWidth) / totalWidth);
4685
4680
  }
4681
+ let outside = [];
4682
+ if (viewFrom > line.from)
4683
+ outside.push({ from: line.from, to: viewFrom });
4684
+ if (viewTo < line.to)
4685
+ outside.push({ from: viewTo, to: line.to });
4686
4686
  let sel = this.state.selection.main;
4687
- // Make sure the gap doesn't cover a selection end
4688
- if (sel.from <= viewFrom && sel.to >= line.from)
4689
- viewFrom = sel.from;
4690
- if (sel.from <= line.to && sel.to >= viewTo)
4691
- viewTo = sel.to;
4692
- let gapTo = viewFrom - 10000 /* Margin */, gapFrom = viewTo + 10000 /* Margin */;
4693
- if (gapTo > line.from + 5000 /* HalfMargin */)
4694
- gaps.push(find(current, gap => gap.from == line.from && gap.to > gapTo - 5000 /* HalfMargin */ && gap.to < gapTo + 5000 /* HalfMargin */) ||
4695
- new LineGap(line.from, gapTo, this.gapSize(line, gapTo, true, structure)));
4696
- if (gapFrom < line.to - 5000 /* HalfMargin */)
4697
- gaps.push(find(current, gap => gap.to == line.to && gap.from > gapFrom - 5000 /* HalfMargin */ &&
4698
- gap.from < gapFrom + 5000 /* HalfMargin */) ||
4699
- new LineGap(gapFrom, line.to, this.gapSize(line, gapFrom, false, structure)));
4687
+ // Make sure the gaps don't cover a selection end
4688
+ if (sel.from >= line.from && sel.from <= line.to)
4689
+ cutRange(outside, sel.from - 10 /* SelectionMargin */, sel.from + 10 /* SelectionMargin */);
4690
+ if (!sel.empty && sel.to >= line.from && sel.to <= line.to)
4691
+ cutRange(outside, sel.to - 10 /* SelectionMargin */, sel.to + 10 /* SelectionMargin */);
4692
+ for (let { from, to } of outside)
4693
+ if (to - from > 1000 /* HalfMargin */) {
4694
+ gaps.push(find(current, gap => gap.from >= line.from && gap.to <= line.to &&
4695
+ Math.abs(gap.from - from) < 1000 /* HalfMargin */ && Math.abs(gap.to - to) < 1000 /* HalfMargin */) ||
4696
+ new LineGap(from, to, this.gapSize(line, from, to, structure)));
4697
+ }
4700
4698
  });
4701
4699
  return gaps;
4702
4700
  }
4703
- gapSize(line, pos, start, structure) {
4701
+ gapSize(line, from, to, structure) {
4702
+ let fraction = findFraction(structure, to) - findFraction(structure, from);
4704
4703
  if (this.heightOracle.lineWrapping) {
4705
- let height = line.height * findFraction(structure, pos);
4706
- return start ? height : line.height - height;
4704
+ return line.height * fraction;
4707
4705
  }
4708
4706
  else {
4709
- let ratio = findFraction(structure, pos);
4710
- return structure.total * this.heightOracle.charWidth * (start ? ratio : 1 - ratio);
4707
+ return structure.total * this.heightOracle.charWidth * fraction;
4711
4708
  }
4712
4709
  }
4713
4710
  updateLineGaps(gaps) {
@@ -4801,6 +4798,20 @@ function findFraction(structure, pos) {
4801
4798
  }
4802
4799
  return counted / structure.total;
4803
4800
  }
4801
+ function cutRange(ranges, from, to) {
4802
+ for (let i = 0; i < ranges.length; i++) {
4803
+ let r = ranges[i];
4804
+ if (r.from < to && r.to > from) {
4805
+ let pieces = [];
4806
+ if (r.from < from)
4807
+ pieces.push({ from: r.from, to: from });
4808
+ if (r.to > to)
4809
+ pieces.push({ from: to, to: r.to });
4810
+ ranges.splice(i, 1, ...pieces);
4811
+ i += pieces.length - 1;
4812
+ }
4813
+ }
4814
+ }
4804
4815
  function find(array, f) {
4805
4816
  for (let val of array)
4806
4817
  if (f(val))
@@ -6265,7 +6276,7 @@ class EditorView {
6265
6276
  target editors with a dark or light theme.
6266
6277
  */
6267
6278
  static baseTheme(spec) {
6268
- return Prec.fallback(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
6279
+ return Prec.lowest(styleModule.of(buildTheme("." + baseThemeID, spec, lightDarkIDs)));
6269
6280
  }
6270
6281
  }
6271
6282
  /**
@@ -6707,7 +6718,7 @@ const themeSpec = {
6707
6718
  };
6708
6719
  if (CanHidePrimary)
6709
6720
  themeSpec[".cm-line"].caretColor = "transparent !important";
6710
- const hideNativeSelection = /*@__PURE__*/Prec.override(/*@__PURE__*/EditorView.theme(themeSpec));
6721
+ const hideNativeSelection = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.theme(themeSpec));
6711
6722
  function getBase(view) {
6712
6723
  let rect = view.scrollDOM.getBoundingClientRect();
6713
6724
  let left = view.textDirection == Direction.LTR ? rect.left : rect.right - view.scrollDOM.clientWidth;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "0.19.11",
3
+ "version": "0.19.12",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",
@@ -27,7 +27,7 @@
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
29
  "@codemirror/rangeset": "^0.19.0",
30
- "@codemirror/state": "^0.19.2",
30
+ "@codemirror/state": "^0.19.3",
31
31
  "@codemirror/text": "^0.19.0",
32
32
  "style-mod": "^4.0.0",
33
33
  "w3c-keyname": "^2.2.4"