@codemirror/autocomplete 6.8.0 → 6.8.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,9 @@
1
+ ## 6.8.1 (2023-06-23)
2
+
3
+ ### Bug fixes
4
+
5
+ `acceptCompletion` now returns false (allowing other handlers to take effect) when the completion popup is open but disabled.
6
+
1
7
  ## 6.8.0 (2023-06-12)
2
8
 
3
9
  ### New features
package/dist/index.cjs CHANGED
@@ -731,9 +731,10 @@ function sortOptions(active, state) {
731
731
  let result = [], prev = null;
732
732
  let compare = state.facet(completionConfig).compareCompletions;
733
733
  for (let opt of options.sort((a, b) => (b.score - a.score) || compare(a.completion, b.completion))) {
734
- if (!prev || prev.label != opt.completion.label || prev.detail != opt.completion.detail ||
735
- (prev.type != null && opt.completion.type != null && prev.type != opt.completion.type) ||
736
- prev.apply != opt.completion.apply)
734
+ let cur = opt.completion;
735
+ if (!prev || prev.label != cur.label || prev.detail != cur.detail ||
736
+ (prev.type != null && cur.type != null && prev.type != cur.type) ||
737
+ prev.apply != cur.apply || prev.boost != cur.boost)
737
738
  result.push(opt);
738
739
  else if (score(opt.completion) > score(prev))
739
740
  result[result.length - 1] = opt;
@@ -977,12 +978,10 @@ Accept the current completion.
977
978
  */
978
979
  const acceptCompletion = (view) => {
979
980
  let cState = view.state.field(completionState, false);
980
- if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 ||
981
+ if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 || cState.open.disabled ||
981
982
  Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
982
983
  return false;
983
- if (!cState.open.disabled)
984
- return applyCompletion(view, cState.open.options[cState.open.selected]);
985
- return true;
984
+ return applyCompletion(view, cState.open.options[cState.open.selected]);
986
985
  };
987
986
  /**
988
987
  Explicitly start autocompletion.
package/dist/index.js CHANGED
@@ -727,9 +727,10 @@ function sortOptions(active, state) {
727
727
  let result = [], prev = null;
728
728
  let compare = state.facet(completionConfig).compareCompletions;
729
729
  for (let opt of options.sort((a, b) => (b.score - a.score) || compare(a.completion, b.completion))) {
730
- if (!prev || prev.label != opt.completion.label || prev.detail != opt.completion.detail ||
731
- (prev.type != null && opt.completion.type != null && prev.type != opt.completion.type) ||
732
- prev.apply != opt.completion.apply)
730
+ let cur = opt.completion;
731
+ if (!prev || prev.label != cur.label || prev.detail != cur.detail ||
732
+ (prev.type != null && cur.type != null && prev.type != cur.type) ||
733
+ prev.apply != cur.apply || prev.boost != cur.boost)
733
734
  result.push(opt);
734
735
  else if (score(opt.completion) > score(prev))
735
736
  result[result.length - 1] = opt;
@@ -973,12 +974,10 @@ Accept the current completion.
973
974
  */
974
975
  const acceptCompletion = (view) => {
975
976
  let cState = view.state.field(completionState, false);
976
- if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 ||
977
+ if (view.state.readOnly || !cState || !cState.open || cState.open.selected < 0 || cState.open.disabled ||
977
978
  Date.now() - cState.open.timestamp < view.state.facet(completionConfig).interactionDelay)
978
979
  return false;
979
- if (!cState.open.disabled)
980
- return applyCompletion(view, cState.open.options[cState.open.selected]);
981
- return true;
980
+ return applyCompletion(view, cState.open.options[cState.open.selected]);
982
981
  };
983
982
  /**
984
983
  Explicitly start autocompletion.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/autocomplete",
3
- "version": "6.8.0",
3
+ "version": "6.8.1",
4
4
  "description": "Autocompletion for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",