@codemirror/autocomplete 6.20.1 → 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,17 @@
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
+
9
+ ## 6.20.2 (2026-05-06)
10
+
11
+ ### Bug fixes
12
+
13
+ Fix an issue where you couldn't move to the last page of completions when its count was a precise multiple of the page size.
14
+
1
15
  ## 6.20.1 (2026-03-02)
2
16
 
3
17
  ### Bug fixes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @codemirror/autocomplete [![NPM version](https://img.shields.io/npm/v/@codemirror/autocomplete.svg)](https://www.npmjs.org/package/@codemirror/autocomplete)
2
2
 
3
- [ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#autocomplete) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/autocomplete/blob/main/CHANGELOG.md) ]
3
+ [ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#autocomplete) | [**ISSUES**](https://code.haverbeke.berlin/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/) | [**CHANGELOG**](https://code.haverbeke.berlin/codemirror/autocomplete/src/branch/main/CHANGELOG.md) ]
4
4
 
5
5
  This package implements autocompletion for the
6
6
  [CodeMirror](https://codemirror.net/) code editor.
@@ -10,7 +10,7 @@ number of [examples](https://codemirror.net/examples/) and the
10
10
  [documentation](https://codemirror.net/docs/).
11
11
 
12
12
  This code is released under an
13
- [MIT license](https://github.com/codemirror/autocomplete/tree/main/LICENSE).
13
+ [MIT license](https://code.haverbeke.berlin/codemirror/autocomplete/tree/main/LICENSE).
14
14
 
15
15
  We aim to be an inclusive, welcoming community. To make that explicit,
16
16
  we have a [code of
package/dist/index.cjs CHANGED
@@ -497,8 +497,8 @@ function rangeAroundSelected(total, selected, max) {
497
497
  let off = Math.floor(selected / max);
498
498
  return { from: off * max, to: (off + 1) * max };
499
499
  }
500
- let off = Math.floor((total - selected) / max);
501
- return { from: total - (off + 1) * max, to: total - off * max };
500
+ let off = Math.ceil((total - selected) / max);
501
+ return { from: total - off * max, to: total - (off - 1) * max };
502
502
  }
503
503
  class CompletionTooltip {
504
504
  constructor(view, stateField, applyCompletion) {
@@ -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);
@@ -1357,7 +1357,8 @@ const baseTheme = view.EditorView.baseTheme({
1357
1357
  content: '"···"',
1358
1358
  opacity: 0.5,
1359
1359
  display: "block",
1360
- textAlign: "center"
1360
+ textAlign: "center",
1361
+ cursor: "pointer",
1361
1362
  },
1362
1363
  ".cm-tooltip.cm-completionInfo": {
1363
1364
  position: "absolute",
@@ -1480,6 +1481,9 @@ class Snippet {
1480
1481
  for (let line of template.split(/\r\n?|\n/)) {
1481
1482
  while (m = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(line)) {
1482
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;
1483
1487
  let name = rawName.replace(/\\[{}]/g, m => m[1]);
1484
1488
  for (let i = 0; i < fields.length; i++) {
1485
1489
  if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
@@ -1594,7 +1598,8 @@ cursor out of the current field deactivates the fields.
1594
1598
 
1595
1599
  The order of fields defaults to textual order, but you can add
1596
1600
  numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
1597
- 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.
1598
1603
 
1599
1604
  To include a literal `{` or `}` in your template, put a backslash
1600
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
@@ -495,8 +495,8 @@ function rangeAroundSelected(total, selected, max) {
495
495
  let off = Math.floor(selected / max);
496
496
  return { from: off * max, to: (off + 1) * max };
497
497
  }
498
- let off = Math.floor((total - selected) / max);
499
- return { from: total - (off + 1) * max, to: total - off * max };
498
+ let off = Math.ceil((total - selected) / max);
499
+ return { from: total - off * max, to: total - (off - 1) * max };
500
500
  }
501
501
  class CompletionTooltip {
502
502
  constructor(view, stateField, applyCompletion) {
@@ -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);
@@ -1355,7 +1355,8 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
1355
1355
  content: '"···"',
1356
1356
  opacity: 0.5,
1357
1357
  display: "block",
1358
- textAlign: "center"
1358
+ textAlign: "center",
1359
+ cursor: "pointer",
1359
1360
  },
1360
1361
  ".cm-tooltip.cm-completionInfo": {
1361
1362
  position: "absolute",
@@ -1478,6 +1479,9 @@ class Snippet {
1478
1479
  for (let line of template.split(/\r\n?|\n/)) {
1479
1480
  while (m = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(line)) {
1480
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;
1481
1485
  let name = rawName.replace(/\\[{}]/g, m => m[1]);
1482
1486
  for (let i = 0; i < fields.length; i++) {
1483
1487
  if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
@@ -1592,7 +1596,8 @@ cursor out of the current field deactivates the fields.
1592
1596
 
1593
1597
  The order of fields defaults to textual order, but you can add
1594
1598
  numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
1595
- 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.
1596
1601
 
1597
1602
  To include a literal `{` or `}` in your template, put a backslash
1598
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.1",
3
+ "version": "6.20.3",
4
4
  "description": "Autocompletion for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",
@@ -36,6 +36,6 @@
36
36
  },
37
37
  "repository": {
38
38
  "type": "git",
39
- "url": "git+https://github.com/codemirror/autocomplete.git"
39
+ "url": "git+https://code.haverbeke.berlin/codemirror/autocomplete.git"
40
40
  }
41
41
  }
@@ -1,16 +0,0 @@
1
- name: Trigger CI
2
- on: push
3
-
4
- jobs:
5
- build:
6
- name: Dispatch to main repo
7
- runs-on: ubuntu-latest
8
- steps:
9
- - name: Emit repository_dispatch
10
- uses: mvasigh/dispatch-action@main
11
- with:
12
- # You should create a personal access token and store it in your repository
13
- token: ${{ secrets.DISPATCH_AUTH }}
14
- repo: dev
15
- owner: codemirror
16
- event_type: push