@codemirror/state 0.19.8 → 0.19.9

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
+ ## 0.19.9 (2022-02-16)
2
+
3
+ ### Bug fixes
4
+
5
+ Mapping a non-empty selection range now always puts any newly inserted text on the sides of the range outside of the mapped version.
6
+
1
7
  ## 0.19.8 (2022-02-15)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -685,7 +685,14 @@ class SelectionRange {
685
685
  updated document.
686
686
  */
687
687
  map(change, assoc = -1) {
688
- let from = change.mapPos(this.from, assoc), to = change.mapPos(this.to, assoc);
688
+ let from, to;
689
+ if (this.empty) {
690
+ from = to = change.mapPos(this.from, assoc);
691
+ }
692
+ else {
693
+ from = change.mapPos(this.from, 1);
694
+ to = change.mapPos(this.to, -1);
695
+ }
689
696
  return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);
690
697
  }
691
698
  /**
package/dist/index.js CHANGED
@@ -681,7 +681,14 @@ class SelectionRange {
681
681
  updated document.
682
682
  */
683
683
  map(change, assoc = -1) {
684
- let from = change.mapPos(this.from, assoc), to = change.mapPos(this.to, assoc);
684
+ let from, to;
685
+ if (this.empty) {
686
+ from = to = change.mapPos(this.from, assoc);
687
+ }
688
+ else {
689
+ from = change.mapPos(this.from, 1);
690
+ to = change.mapPos(this.to, -1);
691
+ }
685
692
  return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);
686
693
  }
687
694
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/state",
3
- "version": "0.19.8",
3
+ "version": "0.19.9",
4
4
  "description": "Editor state data structures for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",