@codemirror/autocomplete 6.20.2 → 6.20.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.20.3 (2026-06-03)
2
+
3
+ ### Bug fixes
4
+
5
+ In snippets, treat tab stop 0 as the final one, aligning with a widely used convention.
6
+
7
+ Fix a bug in the handling of changes before the completion while completion is active.
8
+
1
9
  ## 6.20.2 (2026-05-06)
2
10
 
3
11
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -1029,7 +1029,7 @@ class ActiveResult extends ActiveSource {
1029
1029
  let result = this.result.map ? this.result.map(this.result, mapping) : this.result;
1030
1030
  if (!result)
1031
1031
  return new ActiveSource(this.source, 0 /* State.Inactive */);
1032
- return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
1032
+ return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
1033
1033
  }
1034
1034
  touches(tr) {
1035
1035
  return tr.changes.touchesRange(this.from, this.to);
@@ -1481,6 +1481,9 @@ class Snippet {
1481
1481
  for (let line of template.split(/\r\n?|\n/)) {
1482
1482
  while (m = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(line)) {
1483
1483
  let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1;
1484
+ // `${0}` is the cursor's final position, after every other tab stop.
1485
+ if (seq === 0)
1486
+ seq = 1e9;
1484
1487
  let name = rawName.replace(/\\[{}]/g, m => m[1]);
1485
1488
  for (let i = 0; i < fields.length; i++) {
1486
1489
  if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
@@ -1595,7 +1598,8 @@ cursor out of the current field deactivates the fields.
1595
1598
 
1596
1599
  The order of fields defaults to textual order, but you can add
1597
1600
  numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
1598
- a custom order.
1601
+ a custom order. `${0}` is special—it is always the last stop, where
1602
+ the cursor ends up after tabbing through the other fields.
1599
1603
 
1600
1604
  To include a literal `{` or `}` in your template, put a backslash
1601
1605
  in front of it. This will be removed and the brace will not be
package/dist/index.d.cts CHANGED
@@ -476,7 +476,8 @@ cursor out of the current field deactivates the fields.
476
476
 
477
477
  The order of fields defaults to textual order, but you can add
478
478
  numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
479
- a custom order.
479
+ a custom order. `${0}` is special—it is always the last stop, where
480
+ the cursor ends up after tabbing through the other fields.
480
481
 
481
482
  To include a literal `{` or `}` in your template, put a backslash
482
483
  in front of it. This will be removed and the brace will not be
package/dist/index.d.ts CHANGED
@@ -476,7 +476,8 @@ cursor out of the current field deactivates the fields.
476
476
 
477
477
  The order of fields defaults to textual order, but you can add
478
478
  numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
479
- a custom order.
479
+ a custom order. `${0}` is special—it is always the last stop, where
480
+ the cursor ends up after tabbing through the other fields.
480
481
 
481
482
  To include a literal `{` or `}` in your template, put a backslash
482
483
  in front of it. This will be removed and the brace will not be
package/dist/index.js CHANGED
@@ -1027,7 +1027,7 @@ class ActiveResult extends ActiveSource {
1027
1027
  let result = this.result.map ? this.result.map(this.result, mapping) : this.result;
1028
1028
  if (!result)
1029
1029
  return new ActiveSource(this.source, 0 /* State.Inactive */);
1030
- return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
1030
+ return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
1031
1031
  }
1032
1032
  touches(tr) {
1033
1033
  return tr.changes.touchesRange(this.from, this.to);
@@ -1479,6 +1479,9 @@ class Snippet {
1479
1479
  for (let line of template.split(/\r\n?|\n/)) {
1480
1480
  while (m = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(line)) {
1481
1481
  let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1;
1482
+ // `${0}` is the cursor's final position, after every other tab stop.
1483
+ if (seq === 0)
1484
+ seq = 1e9;
1482
1485
  let name = rawName.replace(/\\[{}]/g, m => m[1]);
1483
1486
  for (let i = 0; i < fields.length; i++) {
1484
1487
  if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
@@ -1593,7 +1596,8 @@ cursor out of the current field deactivates the fields.
1593
1596
 
1594
1597
  The order of fields defaults to textual order, but you can add
1595
1598
  numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
1596
- a custom order.
1599
+ a custom order. `${0}` is special—it is always the last stop, where
1600
+ the cursor ends up after tabbing through the other fields.
1597
1601
 
1598
1602
  To include a literal `{` or `}` in your template, put a backslash
1599
1603
  in front of it. This will be removed and the brace will not be
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/autocomplete",
3
- "version": "6.20.2",
3
+ "version": "6.20.3",
4
4
  "description": "Autocompletion for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",