@codemirror/state 6.5.0 → 6.5.2

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,15 @@
1
+ ## 6.5.2 (2025-02-03)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a bug where reconfiguring a field with a new `init` value didn't update the value of the field.
6
+
7
+ ## 6.5.1 (2025-01-10)
8
+
9
+ ### Bug fixes
10
+
11
+ `countColumn` no longer loops infinitely when given a `to` that's higher than the input string's length.
12
+
1
13
  ## 6.5.0 (2024-12-09)
2
14
 
3
15
  ### New features
package/dist/index.cjs CHANGED
@@ -1777,6 +1777,11 @@ class StateField {
1777
1777
  return 1 /* SlotStatus.Changed */;
1778
1778
  },
1779
1779
  reconfigure: (state, oldState) => {
1780
+ let init = state.facet(initField), oldInit = oldState.facet(initField), reInit;
1781
+ if ((reInit = init.find(i => i.field == this)) && reInit != oldInit.find(i => i.field == this)) {
1782
+ state.values[idx] = reInit.create(state);
1783
+ return 1 /* SlotStatus.Changed */;
1784
+ }
1780
1785
  if (oldState.config.address[this.id] != null) {
1781
1786
  state.values[idx] = oldState.field(this);
1782
1787
  return 0;
@@ -3846,7 +3851,7 @@ taking extending characters and tab size into account.
3846
3851
  */
3847
3852
  function countColumn(string, tabSize, to = string.length) {
3848
3853
  let n = 0;
3849
- for (let i = 0; i < to;) {
3854
+ for (let i = 0; i < to && i < string.length;) {
3850
3855
  if (string.charCodeAt(i) == 9) {
3851
3856
  n += tabSize - (n % tabSize);
3852
3857
  i++;
package/dist/index.d.cts CHANGED
@@ -99,6 +99,9 @@ declare abstract class Text implements Iterable<string> {
99
99
  objects that it is made up of. For leaf nodes, this holds null.
100
100
  */
101
101
  abstract readonly children: readonly Text[] | null;
102
+ /**
103
+ @hide
104
+ */
102
105
  [Symbol.iterator]: () => Iterator<string>;
103
106
  /**
104
107
  Create a `Text` instance for the given array of lines.
package/dist/index.d.ts CHANGED
@@ -99,6 +99,9 @@ declare abstract class Text implements Iterable<string> {
99
99
  objects that it is made up of. For leaf nodes, this holds null.
100
100
  */
101
101
  abstract readonly children: readonly Text[] | null;
102
+ /**
103
+ @hide
104
+ */
102
105
  [Symbol.iterator]: () => Iterator<string>;
103
106
  /**
104
107
  Create a `Text` instance for the given array of lines.
package/dist/index.js CHANGED
@@ -1774,6 +1774,11 @@ class StateField {
1774
1774
  return 1 /* SlotStatus.Changed */;
1775
1775
  },
1776
1776
  reconfigure: (state, oldState) => {
1777
+ let init = state.facet(initField), oldInit = oldState.facet(initField), reInit;
1778
+ if ((reInit = init.find(i => i.field == this)) && reInit != oldInit.find(i => i.field == this)) {
1779
+ state.values[idx] = reInit.create(state);
1780
+ return 1 /* SlotStatus.Changed */;
1781
+ }
1777
1782
  if (oldState.config.address[this.id] != null) {
1778
1783
  state.values[idx] = oldState.field(this);
1779
1784
  return 0;
@@ -3842,7 +3847,7 @@ taking extending characters and tab size into account.
3842
3847
  */
3843
3848
  function countColumn(string, tabSize, to = string.length) {
3844
3849
  let n = 0;
3845
- for (let i = 0; i < to;) {
3850
+ for (let i = 0; i < to && i < string.length;) {
3846
3851
  if (string.charCodeAt(i) == 9) {
3847
3852
  n += tabSize - (n % tabSize);
3848
3853
  i++;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/state",
3
- "version": "6.5.0",
3
+ "version": "6.5.2",
4
4
  "description": "Editor state data structures for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",