@codemirror/autocomplete 6.19.1 → 6.20.1

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,14 @@
1
+ ## 6.20.1 (2026-03-02)
2
+
3
+ ### Bug fixes
4
+
5
+ Clicking the horizontal dots at the top/bottom of a list of completion options now moves the selection there, so that more completions become visible.
6
+ ## 6.20.0 (2025-11-20)
7
+
8
+ ### New features
9
+
10
+ Completions now support a `sortText` property to influence sort order.
11
+
1
12
  ## 6.19.1 (2025-10-23)
2
13
 
3
14
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -391,7 +391,7 @@ const completionConfig = state.Facet.define({
391
391
  addToOptions: [],
392
392
  positionInfo: defaultPositionInfo,
393
393
  filterStrict: false,
394
- compareCompletions: (a, b) => a.label.localeCompare(b.label),
394
+ compareCompletions: (a, b) => (a.sortText || a.label).localeCompare(b.sortText || b.label),
395
395
  interactionDelay: 75,
396
396
  updateSyncTime: 100
397
397
  }, {
@@ -441,6 +441,7 @@ function defaultPositionInfo(view$1, list, option, info, space, tooltip) {
441
441
  };
442
442
  }
443
443
 
444
+ const setSelectedEffect = state.StateEffect.define();
444
445
  function optionContent(config) {
445
446
  let content = config.addToOptions.slice();
446
447
  if (config.icons)
@@ -532,6 +533,16 @@ class CompletionTooltip {
532
533
  return;
533
534
  }
534
535
  }
536
+ if (e.target == this.list) {
537
+ let move = this.list.classList.contains("cm-completionListIncompleteTop") &&
538
+ e.clientY < this.list.firstChild.getBoundingClientRect().top ? this.range.from - 1 :
539
+ this.list.classList.contains("cm-completionListIncompleteBottom") &&
540
+ e.clientY > this.list.lastChild.getBoundingClientRect().bottom ? this.range.to : null;
541
+ if (move != null) {
542
+ view.dispatch({ effects: setSelectedEffect.of(move) });
543
+ e.preventDefault();
544
+ }
545
+ }
535
546
  });
536
547
  this.dom.addEventListener("focusout", (e) => {
537
548
  let state = view.state.field(this.stateField, false);
@@ -1033,7 +1044,6 @@ function checkValid(validFor, state, from, to) {
1033
1044
  const setActiveEffect = state.StateEffect.define({
1034
1045
  map(sources, mapping) { return sources.map(s => s.map(mapping)); }
1035
1046
  });
1036
- const setSelectedEffect = state.StateEffect.define();
1037
1047
  const completionState = state.StateField.define({
1038
1048
  create() { return CompletionState.start(); },
1039
1049
  update(value, tr) { return value.update(tr); },
@@ -1767,7 +1777,8 @@ A completion source that will scan the document for words (using a
1767
1777
  return those as completions.
1768
1778
  */
1769
1779
  const completeAnyWord = context => {
1770
- let wordChars = context.state.languageDataAt("wordChars", context.pos).join("");
1780
+ var _a;
1781
+ let wordChars = (_a = context.state.languageDataAt("wordChars", context.pos)[0]) !== null && _a !== void 0 ? _a : "";
1771
1782
  let re = wordRE(wordChars);
1772
1783
  let token = context.matchBefore(mapRE(re, s => s + "$"));
1773
1784
  if (!token && !context.explicit)
package/dist/index.d.cts CHANGED
@@ -21,6 +21,11 @@ interface Completion {
21
21
  */
22
22
  displayLabel?: string;
23
23
  /**
24
+ Overrides the text that is used to sort completions. Will
25
+ default to `label` if not given.
26
+ */
27
+ sortText?: string;
28
+ /**
24
29
  An optional short piece of information to show (with a different
25
30
  style) after the label.
26
31
  */
package/dist/index.d.ts CHANGED
@@ -21,6 +21,11 @@ interface Completion {
21
21
  */
22
22
  displayLabel?: string;
23
23
  /**
24
+ Overrides the text that is used to sort completions. Will
25
+ default to `label` if not given.
26
+ */
27
+ sortText?: string;
28
+ /**
24
29
  An optional short piece of information to show (with a different
25
30
  style) after the label.
26
31
  */
package/dist/index.js CHANGED
@@ -389,7 +389,7 @@ const completionConfig = /*@__PURE__*/Facet.define({
389
389
  addToOptions: [],
390
390
  positionInfo: defaultPositionInfo,
391
391
  filterStrict: false,
392
- compareCompletions: (a, b) => a.label.localeCompare(b.label),
392
+ compareCompletions: (a, b) => (a.sortText || a.label).localeCompare(b.sortText || b.label),
393
393
  interactionDelay: 75,
394
394
  updateSyncTime: 100
395
395
  }, {
@@ -439,6 +439,7 @@ function defaultPositionInfo(view, list, option, info, space, tooltip) {
439
439
  };
440
440
  }
441
441
 
442
+ const setSelectedEffect = /*@__PURE__*/StateEffect.define();
442
443
  function optionContent(config) {
443
444
  let content = config.addToOptions.slice();
444
445
  if (config.icons)
@@ -530,6 +531,16 @@ class CompletionTooltip {
530
531
  return;
531
532
  }
532
533
  }
534
+ if (e.target == this.list) {
535
+ let move = this.list.classList.contains("cm-completionListIncompleteTop") &&
536
+ e.clientY < this.list.firstChild.getBoundingClientRect().top ? this.range.from - 1 :
537
+ this.list.classList.contains("cm-completionListIncompleteBottom") &&
538
+ e.clientY > this.list.lastChild.getBoundingClientRect().bottom ? this.range.to : null;
539
+ if (move != null) {
540
+ view.dispatch({ effects: setSelectedEffect.of(move) });
541
+ e.preventDefault();
542
+ }
543
+ }
533
544
  });
534
545
  this.dom.addEventListener("focusout", (e) => {
535
546
  let state = view.state.field(this.stateField, false);
@@ -1031,7 +1042,6 @@ function checkValid(validFor, state, from, to) {
1031
1042
  const setActiveEffect = /*@__PURE__*/StateEffect.define({
1032
1043
  map(sources, mapping) { return sources.map(s => s.map(mapping)); }
1033
1044
  });
1034
- const setSelectedEffect = /*@__PURE__*/StateEffect.define();
1035
1045
  const completionState = /*@__PURE__*/StateField.define({
1036
1046
  create() { return CompletionState.start(); },
1037
1047
  update(value, tr) { return value.update(tr); },
@@ -1765,7 +1775,8 @@ A completion source that will scan the document for words (using a
1765
1775
  return those as completions.
1766
1776
  */
1767
1777
  const completeAnyWord = context => {
1768
- let wordChars = context.state.languageDataAt("wordChars", context.pos).join("");
1778
+ var _a;
1779
+ let wordChars = (_a = context.state.languageDataAt("wordChars", context.pos)[0]) !== null && _a !== void 0 ? _a : "";
1769
1780
  let re = wordRE(wordChars);
1770
1781
  let token = context.matchBefore(mapRE(re, s => s + "$"));
1771
1782
  if (!token && !context.explicit)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/autocomplete",
3
- "version": "6.19.1",
3
+ "version": "6.20.1",
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": "https://github.com/codemirror/autocomplete.git"
39
+ "url": "git+https://github.com/codemirror/autocomplete.git"
40
40
  }
41
41
  }