@codemirror/state 6.1.2 → 6.1.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,11 @@
1
+ ## 6.1.3 (2022-11-10)
2
+
3
+ ### Bug fixes
4
+
5
+ Avoid unnecessary calls to computed facet getters when a state is reconfigured but no dependencies of the computed facet change.
6
+
7
+ Fix an infinite loop in `RangeSet.eq` when the `to` parameter isn't given.
8
+
1
9
  ## 6.1.2 (2022-09-21)
2
10
 
3
11
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -1664,18 +1664,20 @@ class FacetProvider {
1664
1664
  return 0;
1665
1665
  },
1666
1666
  reconfigure: (state, oldState) => {
1667
- let newVal = getter(state);
1668
- let oldAddr = oldState.config.address[id];
1667
+ let newVal, oldAddr = oldState.config.address[id];
1669
1668
  if (oldAddr != null) {
1670
1669
  let oldVal = getAddr(oldState, oldAddr);
1671
1670
  if (this.dependencies.every(dep => {
1672
1671
  return dep instanceof Facet ? oldState.facet(dep) === state.facet(dep) :
1673
1672
  dep instanceof StateField ? oldState.field(dep, false) == state.field(dep, false) : true;
1674
- }) || (multi ? compareArray(newVal, oldVal, compare) : compare(newVal, oldVal))) {
1673
+ }) || (multi ? compareArray(newVal = getter(state), oldVal, compare) : compare(newVal = getter(state), oldVal))) {
1675
1674
  state.values[idx] = oldVal;
1676
1675
  return 0;
1677
1676
  }
1678
1677
  }
1678
+ else {
1679
+ newVal = getter(state);
1680
+ }
1679
1681
  state.values[idx] = newVal;
1680
1682
  return 1 /* SlotStatus.Changed */;
1681
1683
  }
@@ -2810,6 +2812,18 @@ class EditorState {
2810
2812
  /**
2811
2813
  Find the values for a given language data field, provided by the
2812
2814
  the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
2815
+
2816
+ Examples of language data fields are...
2817
+
2818
+ - [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
2819
+ comment syntax.
2820
+ - [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
2821
+ for providing language-specific completion sources.
2822
+ - [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
2823
+ characters that should be considered part of words in this
2824
+ language.
2825
+ - [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
2826
+ bracket closing behavior.
2813
2827
  */
2814
2828
  languageDataAt(name, pos, side = -1) {
2815
2829
  let values = [];
@@ -3314,7 +3328,7 @@ class RangeSet {
3314
3328
  */
3315
3329
  static eq(oldSets, newSets, from = 0, to) {
3316
3330
  if (to == null)
3317
- to = 1000000000 /* C.Far */;
3331
+ to = 1000000000 /* C.Far */ - 1;
3318
3332
  let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
3319
3333
  let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
3320
3334
  if (a.length != b.length)
package/dist/index.d.ts CHANGED
@@ -1228,6 +1228,18 @@ declare class EditorState {
1228
1228
  /**
1229
1229
  Find the values for a given language data field, provided by the
1230
1230
  the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
1231
+
1232
+ Examples of language data fields are...
1233
+
1234
+ - [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
1235
+ comment syntax.
1236
+ - [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
1237
+ for providing language-specific completion sources.
1238
+ - [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
1239
+ characters that should be considered part of words in this
1240
+ language.
1241
+ - [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
1242
+ bracket closing behavior.
1231
1243
  */
1232
1244
  languageDataAt<T>(name: string, pos: number, side?: -1 | 0 | 1): readonly T[];
1233
1245
  /**
package/dist/index.js CHANGED
@@ -1659,18 +1659,20 @@ class FacetProvider {
1659
1659
  return 0;
1660
1660
  },
1661
1661
  reconfigure: (state, oldState) => {
1662
- let newVal = getter(state);
1663
- let oldAddr = oldState.config.address[id];
1662
+ let newVal, oldAddr = oldState.config.address[id];
1664
1663
  if (oldAddr != null) {
1665
1664
  let oldVal = getAddr(oldState, oldAddr);
1666
1665
  if (this.dependencies.every(dep => {
1667
1666
  return dep instanceof Facet ? oldState.facet(dep) === state.facet(dep) :
1668
1667
  dep instanceof StateField ? oldState.field(dep, false) == state.field(dep, false) : true;
1669
- }) || (multi ? compareArray(newVal, oldVal, compare) : compare(newVal, oldVal))) {
1668
+ }) || (multi ? compareArray(newVal = getter(state), oldVal, compare) : compare(newVal = getter(state), oldVal))) {
1670
1669
  state.values[idx] = oldVal;
1671
1670
  return 0;
1672
1671
  }
1673
1672
  }
1673
+ else {
1674
+ newVal = getter(state);
1675
+ }
1674
1676
  state.values[idx] = newVal;
1675
1677
  return 1 /* SlotStatus.Changed */;
1676
1678
  }
@@ -2804,6 +2806,18 @@ class EditorState {
2804
2806
  /**
2805
2807
  Find the values for a given language data field, provided by the
2806
2808
  the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
2809
+
2810
+ Examples of language data fields are...
2811
+
2812
+ - [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
2813
+ comment syntax.
2814
+ - [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
2815
+ for providing language-specific completion sources.
2816
+ - [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
2817
+ characters that should be considered part of words in this
2818
+ language.
2819
+ - [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
2820
+ bracket closing behavior.
2807
2821
  */
2808
2822
  languageDataAt(name, pos, side = -1) {
2809
2823
  let values = [];
@@ -3308,7 +3322,7 @@ class RangeSet {
3308
3322
  */
3309
3323
  static eq(oldSets, newSets, from = 0, to) {
3310
3324
  if (to == null)
3311
- to = 1000000000 /* C.Far */;
3325
+ to = 1000000000 /* C.Far */ - 1;
3312
3326
  let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);
3313
3327
  let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);
3314
3328
  if (a.length != b.length)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/state",
3
- "version": "6.1.2",
3
+ "version": "6.1.3",
4
4
  "description": "Editor state data structures for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",