@codemirror/state 0.18.6 → 0.18.7

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.18.7 (2021-05-04)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix an issue where state fields might be initialized with a state that they aren't actually part of during reconfiguration.
6
+
1
7
  ## 0.18.6 (2021-04-12)
2
8
 
3
9
  ### New features
package/dist/index.cjs CHANGED
@@ -1071,14 +1071,13 @@ class StateField {
1071
1071
  slot(addresses) {
1072
1072
  let idx = addresses[this.id] >> 1;
1073
1073
  return (state, tr) => {
1074
- if (!tr) {
1074
+ if (!tr || (tr.reconfigured && maybeIndex(tr.startState, this.id) == null)) {
1075
1075
  state.values[idx] = this.create(state);
1076
1076
  return 1 /* Changed */;
1077
1077
  }
1078
1078
  let oldVal, changed = 0;
1079
1079
  if (tr.reconfigured) {
1080
- let oldIdx = maybeIndex(tr.startState, this.id);
1081
- oldVal = oldIdx == null ? this.create(tr.startState) : tr.startState.values[oldIdx];
1080
+ oldVal = tr.startState.values[maybeIndex(tr.startState, this.id)];
1082
1081
  changed = 1 /* Changed */;
1083
1082
  }
1084
1083
  else {
package/dist/index.js CHANGED
@@ -1067,14 +1067,13 @@ class StateField {
1067
1067
  slot(addresses) {
1068
1068
  let idx = addresses[this.id] >> 1;
1069
1069
  return (state, tr) => {
1070
- if (!tr) {
1070
+ if (!tr || (tr.reconfigured && maybeIndex(tr.startState, this.id) == null)) {
1071
1071
  state.values[idx] = this.create(state);
1072
1072
  return 1 /* Changed */;
1073
1073
  }
1074
1074
  let oldVal, changed = 0;
1075
1075
  if (tr.reconfigured) {
1076
- let oldIdx = maybeIndex(tr.startState, this.id);
1077
- oldVal = oldIdx == null ? this.create(tr.startState) : tr.startState.values[oldIdx];
1076
+ oldVal = tr.startState.values[maybeIndex(tr.startState, this.id)];
1078
1077
  changed = 1 /* Changed */;
1079
1078
  }
1080
1079
  else {
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@codemirror/state",
3
- "version": "0.18.6",
3
+ "version": "0.18.7",
4
4
  "description": "Editor state data structures for the CodeMirror code editor",
5
5
  "scripts": {
6
- "test": "mocha test/test-*.js",
6
+ "test": "cm-runtests",
7
7
  "prepare": "cm-buildhelper src/index.ts"
8
8
  },
9
9
  "keywords": [
@@ -29,10 +29,7 @@
29
29
  "@codemirror/text": "^0.18.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@codemirror/buildhelper": "^0.1.0",
33
- "@types/mocha": "^5.2.0",
34
- "ist": "^1.1.6",
35
- "mocha": "^7.1.1"
32
+ "@codemirror/buildhelper": "^0.1.5"
36
33
  },
37
34
  "repository": {
38
35
  "type": "git",