@codemirror/autocomplete 6.1.0 → 6.1.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,11 @@
1
+ ## 6.1.1 (2022-09-08)
2
+
3
+ ### Bug fixes
4
+
5
+ Fix a bug that prevented transactions produced by `deleteBracketPair` from being marked as deletion user events.
6
+
7
+ Improve positioning of completion info tooltips so they are less likely to stick out of the screen on small displays.
8
+
1
9
  ## 6.1.0 (2022-07-19)
2
10
 
3
11
  ### New features
package/dist/index.cjs CHANGED
@@ -233,7 +233,7 @@ class FuzzyMatcher {
233
233
  if (chars.length == 1) {
234
234
  let first = state.codePointAt(word, 0);
235
235
  return first == chars[0] ? [0, 0, state.codePointSize(first)]
236
- : first == folded[0] ? [-200 /* CaseFold */, 0, state.codePointSize(first)] : null;
236
+ : first == folded[0] ? [-200 /* Penalty.CaseFold */, 0, state.codePointSize(first)] : null;
237
237
  }
238
238
  let direct = word.indexOf(this.pattern);
239
239
  if (direct == 0)
@@ -261,7 +261,7 @@ class FuzzyMatcher {
261
261
  let adjacentTo = 0, adjacentStart = -1, adjacentEnd = -1;
262
262
  let hasLower = /[a-z]/.test(word), wordAdjacent = true;
263
263
  // Go over the option's text, scanning for the various kinds of matches
264
- for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* NonWord */; i < e && byWordTo < len;) {
264
+ for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* Tp.NonWord */; i < e && byWordTo < len;) {
265
265
  let next = state.codePointAt(word, i);
266
266
  if (direct < 0) {
267
267
  if (preciseTo < len && next == chars[preciseTo])
@@ -279,9 +279,9 @@ class FuzzyMatcher {
279
279
  }
280
280
  }
281
281
  let ch, type = next < 0xff
282
- ? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Lower */ : next >= 65 && next <= 90 ? 1 /* Upper */ : 0 /* NonWord */)
283
- : ((ch = state.fromCodePoint(next)) != ch.toLowerCase() ? 1 /* Upper */ : ch != ch.toUpperCase() ? 2 /* Lower */ : 0 /* NonWord */);
284
- if (!i || type == 1 /* Upper */ && hasLower || prevType == 0 /* NonWord */ && type != 0 /* NonWord */) {
282
+ ? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Tp.Lower */ : next >= 65 && next <= 90 ? 1 /* Tp.Upper */ : 0 /* Tp.NonWord */)
283
+ : ((ch = state.fromCodePoint(next)) != ch.toLowerCase() ? 1 /* Tp.Upper */ : ch != ch.toUpperCase() ? 2 /* Tp.Lower */ : 0 /* Tp.NonWord */);
284
+ if (!i || type == 1 /* Tp.Upper */ && hasLower || prevType == 0 /* Tp.NonWord */ && type != 0 /* Tp.NonWord */) {
285
285
  if (chars[byWordTo] == next || (folded[byWordTo] == next && (byWordFolded = true)))
286
286
  byWord[byWordTo++] = i;
287
287
  else if (byWord.length)
@@ -291,17 +291,17 @@ class FuzzyMatcher {
291
291
  i += state.codePointSize(next);
292
292
  }
293
293
  if (byWordTo == len && byWord[0] == 0 && wordAdjacent)
294
- return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0), byWord, word);
294
+ return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0), byWord, word);
295
295
  if (adjacentTo == len && adjacentStart == 0)
296
- return [-200 /* CaseFold */ - word.length, 0, adjacentEnd];
296
+ return [-200 /* Penalty.CaseFold */ - word.length, 0, adjacentEnd];
297
297
  if (direct > -1)
298
- return [-700 /* NotStart */ - word.length, direct, direct + this.pattern.length];
298
+ return [-700 /* Penalty.NotStart */ - word.length, direct, direct + this.pattern.length];
299
299
  if (adjacentTo == len)
300
- return [-200 /* CaseFold */ + -700 /* NotStart */ - word.length, adjacentStart, adjacentEnd];
300
+ return [-200 /* Penalty.CaseFold */ + -700 /* Penalty.NotStart */ - word.length, adjacentStart, adjacentEnd];
301
301
  if (byWordTo == len)
302
- return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0) + -700 /* NotStart */ +
303
- (wordAdjacent ? 0 : -1100 /* Gap */), byWord, word);
304
- return chars.length == 2 ? null : this.result((any[0] ? -700 /* NotStart */ : 0) + -200 /* CaseFold */ + -1100 /* Gap */, any, word);
302
+ return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0) + -700 /* Penalty.NotStart */ +
303
+ (wordAdjacent ? 0 : -1100 /* Penalty.Gap */), byWord, word);
304
+ return chars.length == 2 ? null : this.result((any[0] ? -700 /* Penalty.NotStart */ : 0) + -200 /* Penalty.CaseFold */ + -1100 /* Penalty.Gap */, any, word);
305
305
  }
306
306
  result(score, positions, word) {
307
307
  let result = [score - word.length], i = 1;
@@ -447,7 +447,7 @@ class CompletionTooltip {
447
447
  }
448
448
  updateSel() {
449
449
  let cState = this.view.state.field(this.stateField), open = cState.open;
450
- if (open.selected < this.range.from || open.selected >= this.range.to) {
450
+ if (open.selected > -1 && open.selected < this.range.from || open.selected >= this.range.to) {
451
451
  this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions);
452
452
  this.list.remove();
453
453
  this.list = this.dom.appendChild(this.createListBox(open.options, cState.id, this.range));
@@ -508,26 +508,47 @@ class CompletionTooltip {
508
508
  let sel = this.dom.querySelector("[aria-selected]");
509
509
  if (!sel || !this.info)
510
510
  return null;
511
+ let win = this.dom.ownerDocument.defaultView;
511
512
  let listRect = this.dom.getBoundingClientRect();
512
513
  let infoRect = this.info.getBoundingClientRect();
513
514
  let selRect = sel.getBoundingClientRect();
514
- if (selRect.top > Math.min(innerHeight, listRect.bottom) - 10 || selRect.bottom < Math.max(0, listRect.top) + 10)
515
+ if (selRect.top > Math.min(win.innerHeight, listRect.bottom) - 10 || selRect.bottom < Math.max(0, listRect.top) + 10)
515
516
  return null;
516
- let top = Math.max(0, Math.min(selRect.top, innerHeight - infoRect.height)) - listRect.top;
517
- let left = this.view.textDirection == view.Direction.RTL;
518
- let spaceLeft = listRect.left, spaceRight = innerWidth - listRect.right;
517
+ let rtl = this.view.textDirection == view.Direction.RTL, left = rtl, narrow = false, maxWidth;
518
+ let top = "", bottom = "";
519
+ let spaceLeft = listRect.left, spaceRight = win.innerWidth - listRect.right;
519
520
  if (left && spaceLeft < Math.min(infoRect.width, spaceRight))
520
521
  left = false;
521
522
  else if (!left && spaceRight < Math.min(infoRect.width, spaceLeft))
522
523
  left = true;
523
- return { top, left };
524
+ if (infoRect.width <= (left ? spaceLeft : spaceRight)) {
525
+ top = (Math.max(0, Math.min(selRect.top, win.innerHeight - infoRect.height)) - listRect.top) + "px";
526
+ maxWidth = Math.min(400 /* Info.Width */, left ? spaceLeft : spaceRight) + "px";
527
+ }
528
+ else {
529
+ narrow = true;
530
+ maxWidth = Math.min(400 /* Info.Width */, (rtl ? listRect.right : win.innerWidth - listRect.left) - 30 /* Info.Margin */) + "px";
531
+ let spaceBelow = win.innerHeight - listRect.bottom;
532
+ if (spaceBelow >= infoRect.height || spaceBelow > listRect.top) // Below the completion
533
+ top = (selRect.bottom - listRect.top) + "px";
534
+ else // Above it
535
+ bottom = (listRect.bottom - selRect.top) + "px";
536
+ }
537
+ return {
538
+ top, bottom, maxWidth,
539
+ class: narrow ? (rtl ? "left-narrow" : "right-narrow") : left ? "left" : "right",
540
+ };
524
541
  }
525
542
  positionInfo(pos) {
526
543
  if (this.info) {
527
- this.info.style.top = (pos ? pos.top : -1e6) + "px";
528
544
  if (pos) {
529
- this.info.classList.toggle("cm-completionInfo-left", pos.left);
530
- this.info.classList.toggle("cm-completionInfo-right", !pos.left);
545
+ this.info.style.top = pos.top;
546
+ this.info.style.bottom = pos.bottom;
547
+ this.info.style.maxWidth = pos.maxWidth;
548
+ this.info.className = "cm-tooltip cm-completionInfo cm-completionInfo-" + pos.class;
549
+ }
550
+ else {
551
+ this.info.style.top = "-1e6px";
531
552
  }
532
553
  }
533
554
  }
@@ -665,7 +686,7 @@ class CompletionState {
665
686
  state.languageDataAt("autocomplete", cur(state)).map(asSource);
666
687
  let active = sources.map(source => {
667
688
  let value = this.active.find(s => s.source == source) ||
668
- new ActiveSource(source, this.active.some(a => a.state != 0 /* Inactive */) ? 1 /* Pending */ : 0 /* Inactive */);
689
+ new ActiveSource(source, this.active.some(a => a.state != 0 /* State.Inactive */) ? 1 /* State.Pending */ : 0 /* State.Inactive */);
669
690
  return value.update(tr, conf);
670
691
  });
671
692
  if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
@@ -673,8 +694,8 @@ class CompletionState {
673
694
  let open = tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
674
695
  !sameResults(active, this.active) ? CompletionDialog.build(active, state, this.id, this.open, conf)
675
696
  : this.open && tr.docChanged ? this.open.map(tr.changes) : this.open;
676
- if (!open && active.every(a => a.state != 1 /* Pending */) && active.some(a => a.hasResult()))
677
- active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* Inactive */) : a);
697
+ if (!open && active.every(a => a.state != 1 /* State.Pending */) && active.some(a => a.hasResult()))
698
+ active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* State.Inactive */) : a);
678
699
  for (let effect of tr.effects)
679
700
  if (effect.is(setSelectedEffect))
680
701
  open = open && open.setSelected(effect.value, this.id);
@@ -728,13 +749,13 @@ class ActiveSource {
728
749
  value = value.handleUserEvent(tr, event, conf);
729
750
  else if (tr.docChanged)
730
751
  value = value.handleChange(tr);
731
- else if (tr.selection && value.state != 0 /* Inactive */)
732
- value = new ActiveSource(value.source, 0 /* Inactive */);
752
+ else if (tr.selection && value.state != 0 /* State.Inactive */)
753
+ value = new ActiveSource(value.source, 0 /* State.Inactive */);
733
754
  for (let effect of tr.effects) {
734
755
  if (effect.is(startCompletionEffect))
735
- value = new ActiveSource(value.source, 1 /* Pending */, effect.value ? cur(tr.state) : -1);
756
+ value = new ActiveSource(value.source, 1 /* State.Pending */, effect.value ? cur(tr.state) : -1);
736
757
  else if (effect.is(closeCompletionEffect))
737
- value = new ActiveSource(value.source, 0 /* Inactive */);
758
+ value = new ActiveSource(value.source, 0 /* State.Inactive */);
738
759
  else if (effect.is(setActiveEffect))
739
760
  for (let active of effect.value)
740
761
  if (active.source == value.source)
@@ -743,10 +764,10 @@ class ActiveSource {
743
764
  return value;
744
765
  }
745
766
  handleUserEvent(tr, type, conf) {
746
- return type == "delete" || !conf.activateOnTyping ? this.map(tr.changes) : new ActiveSource(this.source, 1 /* Pending */);
767
+ return type == "delete" || !conf.activateOnTyping ? this.map(tr.changes) : new ActiveSource(this.source, 1 /* State.Pending */);
747
768
  }
748
769
  handleChange(tr) {
749
- return tr.changes.touchesRange(cur(tr.startState)) ? new ActiveSource(this.source, 0 /* Inactive */) : this.map(tr.changes);
770
+ return tr.changes.touchesRange(cur(tr.startState)) ? new ActiveSource(this.source, 0 /* State.Inactive */) : this.map(tr.changes);
750
771
  }
751
772
  map(changes) {
752
773
  return changes.empty || this.explicitPos < 0 ? this : new ActiveSource(this.source, this.state, changes.mapPos(this.explicitPos));
@@ -754,7 +775,7 @@ class ActiveSource {
754
775
  }
755
776
  class ActiveResult extends ActiveSource {
756
777
  constructor(source, explicitPos, result, from, to) {
757
- super(source, 2 /* Result */, explicitPos);
778
+ super(source, 2 /* State.Result */, explicitPos);
758
779
  this.result = result;
759
780
  this.from = from;
760
781
  this.to = to;
@@ -767,17 +788,17 @@ class ActiveResult extends ActiveSource {
767
788
  if ((this.explicitPos < 0 ? pos <= from : pos < this.from) ||
768
789
  pos > to ||
769
790
  type == "delete" && cur(tr.startState) == this.from)
770
- return new ActiveSource(this.source, type == "input" && conf.activateOnTyping ? 1 /* Pending */ : 0 /* Inactive */);
791
+ return new ActiveSource(this.source, type == "input" && conf.activateOnTyping ? 1 /* State.Pending */ : 0 /* State.Inactive */);
771
792
  let explicitPos = this.explicitPos < 0 ? -1 : tr.changes.mapPos(this.explicitPos), updated;
772
793
  if (checkValid(this.result.validFor, tr.state, from, to))
773
794
  return new ActiveResult(this.source, explicitPos, this.result, from, to);
774
795
  if (this.result.update &&
775
796
  (updated = this.result.update(this.result, from, to, new CompletionContext(tr.state, pos, explicitPos >= 0))))
776
797
  return new ActiveResult(this.source, explicitPos, updated, updated.from, (_a = updated.to) !== null && _a !== void 0 ? _a : cur(tr.state));
777
- return new ActiveSource(this.source, 1 /* Pending */, explicitPos);
798
+ return new ActiveSource(this.source, 1 /* State.Pending */, explicitPos);
778
799
  }
779
800
  handleChange(tr) {
780
- return tr.changes.touchesRange(this.from, this.to) ? new ActiveSource(this.source, 0 /* Inactive */) : this.map(tr.changes);
801
+ return tr.changes.touchesRange(this.from, this.to) ? new ActiveSource(this.source, 0 /* State.Inactive */) : this.map(tr.changes);
781
802
  }
782
803
  map(mapping) {
783
804
  return mapping.empty ? this :
@@ -855,7 +876,7 @@ Close the currently active completion.
855
876
  */
856
877
  const closeCompletion = (view) => {
857
878
  let cState = view.state.field(completionState, false);
858
- if (!cState || !cState.active.some(a => a.state != 0 /* Inactive */))
879
+ if (!cState || !cState.active.some(a => a.state != 0 /* State.Inactive */))
859
880
  return false;
860
881
  view.dispatch({ effects: closeCompletionEffect.of(null) });
861
882
  return true;
@@ -878,9 +899,9 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
878
899
  this.debounceUpdate = -1;
879
900
  this.running = [];
880
901
  this.debounceAccept = -1;
881
- this.composing = 0 /* None */;
902
+ this.composing = 0 /* CompositionState.None */;
882
903
  for (let active of view.state.field(completionState).active)
883
- if (active.state == 1 /* Pending */)
904
+ if (active.state == 1 /* State.Pending */)
884
905
  this.startQuery(active);
885
906
  }
886
907
  update(update) {
@@ -911,21 +932,21 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
911
932
  }
912
933
  if (this.debounceUpdate > -1)
913
934
  clearTimeout(this.debounceUpdate);
914
- this.debounceUpdate = cState.active.some(a => a.state == 1 /* Pending */ && !this.running.some(q => q.active.source == a.source))
935
+ this.debounceUpdate = cState.active.some(a => a.state == 1 /* State.Pending */ && !this.running.some(q => q.active.source == a.source))
915
936
  ? setTimeout(() => this.startUpdate(), DebounceTime) : -1;
916
- if (this.composing != 0 /* None */)
937
+ if (this.composing != 0 /* CompositionState.None */)
917
938
  for (let tr of update.transactions) {
918
939
  if (getUserEvent(tr) == "input")
919
- this.composing = 2 /* Changed */;
920
- else if (this.composing == 2 /* Changed */ && tr.selection)
921
- this.composing = 3 /* ChangedAndMoved */;
940
+ this.composing = 2 /* CompositionState.Changed */;
941
+ else if (this.composing == 2 /* CompositionState.Changed */ && tr.selection)
942
+ this.composing = 3 /* CompositionState.ChangedAndMoved */;
922
943
  }
923
944
  }
924
945
  startUpdate() {
925
946
  this.debounceUpdate = -1;
926
947
  let { state } = this.view, cState = state.field(completionState);
927
948
  for (let active of cState.active) {
928
- if (active.state == 1 /* Pending */ && !this.running.some(r => r.active.source == active.source))
949
+ if (active.state == 1 /* State.Pending */ && !this.running.some(r => r.active.source == active.source))
929
950
  this.startQuery(active);
930
951
  }
931
952
  }
@@ -976,14 +997,14 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
976
997
  }
977
998
  }
978
999
  let current = this.view.state.field(completionState).active.find(a => a.source == query.active.source);
979
- if (current && current.state == 1 /* Pending */) {
1000
+ if (current && current.state == 1 /* State.Pending */) {
980
1001
  if (query.done == null) {
981
1002
  // Explicitly failed. Should clear the pending status if it
982
1003
  // hasn't been re-set in the meantime.
983
- let active = new ActiveSource(query.active.source, 0 /* Inactive */);
1004
+ let active = new ActiveSource(query.active.source, 0 /* State.Inactive */);
984
1005
  for (let tr of query.updates)
985
1006
  active = active.update(tr, conf);
986
- if (active.state != 1 /* Pending */)
1007
+ if (active.state != 1 /* State.Pending */)
987
1008
  updated.push(active);
988
1009
  }
989
1010
  else {
@@ -1003,15 +1024,15 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
1003
1024
  this.view.dispatch({ effects: closeCompletionEffect.of(null) });
1004
1025
  },
1005
1026
  compositionstart() {
1006
- this.composing = 1 /* Started */;
1027
+ this.composing = 1 /* CompositionState.Started */;
1007
1028
  },
1008
1029
  compositionend() {
1009
- if (this.composing == 3 /* ChangedAndMoved */) {
1030
+ if (this.composing == 3 /* CompositionState.ChangedAndMoved */) {
1010
1031
  // Safari fires compositionend events synchronously, possibly
1011
1032
  // from inside an update, so dispatch asynchronously to avoid reentrancy
1012
1033
  setTimeout(() => this.view.dispatch({ effects: startCompletionEffect.of(false) }), 20);
1013
1034
  }
1014
- this.composing = 0 /* None */;
1035
+ this.composing = 0 /* CompositionState.None */;
1015
1036
  }
1016
1037
  }
1017
1038
  });
@@ -1056,10 +1077,13 @@ const baseTheme = view.EditorView.baseTheme({
1056
1077
  position: "absolute",
1057
1078
  padding: "3px 9px",
1058
1079
  width: "max-content",
1059
- maxWidth: "300px",
1080
+ maxWidth: `${400 /* Info.Width */}px`,
1081
+ boxSizing: "border-box"
1060
1082
  },
1061
1083
  ".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
1062
1084
  ".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
1085
+ ".cm-completionInfo.cm-completionInfo-left-narrow": { right: `${30 /* Info.Margin */}px` },
1086
+ ".cm-completionInfo.cm-completionInfo-right-narrow": { left: `${30 /* Info.Margin */}px` },
1063
1087
  "&light .cm-snippetField": { backgroundColor: "#00000022" },
1064
1088
  "&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
1065
1089
  ".cm-snippetFieldPosition": {
@@ -1394,7 +1418,7 @@ function storeWords(doc, wordRE, result, seen, ignoreAt) {
1394
1418
  if (!seen[m[0]] && pos + m.index != ignoreAt) {
1395
1419
  result.push({ type: "text", label: m[0] });
1396
1420
  seen[m[0]] = true;
1397
- if (result.length >= 2000 /* MaxList */)
1421
+ if (result.length >= 2000 /* C.MaxList */)
1398
1422
  return;
1399
1423
  }
1400
1424
  }
@@ -1402,7 +1426,7 @@ function storeWords(doc, wordRE, result, seen, ignoreAt) {
1402
1426
  }
1403
1427
  }
1404
1428
  function collectWords(doc, cache, wordRE, to, ignoreAt) {
1405
- let big = doc.length >= 1000 /* MinCacheLen */;
1429
+ let big = doc.length >= 1000 /* C.MinCacheLen */;
1406
1430
  let cached = big && cache.get(doc);
1407
1431
  if (cached)
1408
1432
  return cached;
@@ -1410,7 +1434,7 @@ function collectWords(doc, cache, wordRE, to, ignoreAt) {
1410
1434
  if (doc.children) {
1411
1435
  let pos = 0;
1412
1436
  for (let ch of doc.children) {
1413
- if (ch.length >= 1000 /* MinCacheLen */) {
1437
+ if (ch.length >= 1000 /* C.MinCacheLen */) {
1414
1438
  for (let c of collectWords(ch, cache, wordRE, to - pos, ignoreAt - pos)) {
1415
1439
  if (!seen[c.label]) {
1416
1440
  seen[c.label] = true;
@@ -1427,7 +1451,7 @@ function collectWords(doc, cache, wordRE, to, ignoreAt) {
1427
1451
  else {
1428
1452
  storeWords(doc, wordRE, result, seen, ignoreAt);
1429
1453
  }
1430
- if (big && result.length < 2000 /* MaxList */)
1454
+ if (big && result.length < 2000 /* C.MaxList */)
1431
1455
  cache.set(doc, result);
1432
1456
  return result;
1433
1457
  }
@@ -1443,7 +1467,7 @@ const completeAnyWord = context => {
1443
1467
  if (!token && !context.explicit)
1444
1468
  return null;
1445
1469
  let from = token ? token.from : context.pos;
1446
- let options = collectWords(context.state.doc, wordCache(wordChars), re, 50000 /* Range */, from);
1470
+ let options = collectWords(context.state.doc, wordCache(wordChars), re, 50000 /* C.Range */, from);
1447
1471
  return { from, options, validFor: mapRE(re, s => "^" + s) };
1448
1472
  };
1449
1473
 
@@ -1532,14 +1556,13 @@ const deleteBracketPair = ({ state: state$1, dispatch }) => {
1532
1556
  for (let token of tokens) {
1533
1557
  if (token == before && nextChar(state$1.doc, range.head) == closing(state.codePointAt(token, 0)))
1534
1558
  return { changes: { from: range.head - token.length, to: range.head + token.length },
1535
- range: state.EditorSelection.cursor(range.head - token.length),
1536
- userEvent: "delete.backward" };
1559
+ range: state.EditorSelection.cursor(range.head - token.length) };
1537
1560
  }
1538
1561
  }
1539
1562
  return { range: dont = range };
1540
1563
  });
1541
1564
  if (!dont)
1542
- dispatch(state$1.update(changes, { scrollIntoView: true }));
1565
+ dispatch(state$1.update(changes, { scrollIntoView: true, userEvent: "delete.backward" }));
1543
1566
  return !dont;
1544
1567
  };
1545
1568
  /**
@@ -1725,8 +1748,8 @@ returns `null`.
1725
1748
  */
1726
1749
  function completionStatus(state) {
1727
1750
  let cState = state.field(completionState, false);
1728
- return cState && cState.active.some(a => a.state == 1 /* Pending */) ? "pending"
1729
- : cState && cState.active.some(a => a.state != 0 /* Inactive */) ? "active" : null;
1751
+ return cState && cState.active.some(a => a.state == 1 /* State.Pending */) ? "pending"
1752
+ : cState && cState.active.some(a => a.state != 0 /* State.Inactive */) ? "active" : null;
1730
1753
  }
1731
1754
  const completionArrayCache = new WeakMap;
1732
1755
  /**
package/dist/index.js CHANGED
@@ -229,7 +229,7 @@ class FuzzyMatcher {
229
229
  if (chars.length == 1) {
230
230
  let first = codePointAt(word, 0);
231
231
  return first == chars[0] ? [0, 0, codePointSize(first)]
232
- : first == folded[0] ? [-200 /* CaseFold */, 0, codePointSize(first)] : null;
232
+ : first == folded[0] ? [-200 /* Penalty.CaseFold */, 0, codePointSize(first)] : null;
233
233
  }
234
234
  let direct = word.indexOf(this.pattern);
235
235
  if (direct == 0)
@@ -257,7 +257,7 @@ class FuzzyMatcher {
257
257
  let adjacentTo = 0, adjacentStart = -1, adjacentEnd = -1;
258
258
  let hasLower = /[a-z]/.test(word), wordAdjacent = true;
259
259
  // Go over the option's text, scanning for the various kinds of matches
260
- for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* NonWord */; i < e && byWordTo < len;) {
260
+ for (let i = 0, e = Math.min(word.length, 200), prevType = 0 /* Tp.NonWord */; i < e && byWordTo < len;) {
261
261
  let next = codePointAt(word, i);
262
262
  if (direct < 0) {
263
263
  if (preciseTo < len && next == chars[preciseTo])
@@ -275,9 +275,9 @@ class FuzzyMatcher {
275
275
  }
276
276
  }
277
277
  let ch, type = next < 0xff
278
- ? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Lower */ : next >= 65 && next <= 90 ? 1 /* Upper */ : 0 /* NonWord */)
279
- : ((ch = fromCodePoint(next)) != ch.toLowerCase() ? 1 /* Upper */ : ch != ch.toUpperCase() ? 2 /* Lower */ : 0 /* NonWord */);
280
- if (!i || type == 1 /* Upper */ && hasLower || prevType == 0 /* NonWord */ && type != 0 /* NonWord */) {
278
+ ? (next >= 48 && next <= 57 || next >= 97 && next <= 122 ? 2 /* Tp.Lower */ : next >= 65 && next <= 90 ? 1 /* Tp.Upper */ : 0 /* Tp.NonWord */)
279
+ : ((ch = fromCodePoint(next)) != ch.toLowerCase() ? 1 /* Tp.Upper */ : ch != ch.toUpperCase() ? 2 /* Tp.Lower */ : 0 /* Tp.NonWord */);
280
+ if (!i || type == 1 /* Tp.Upper */ && hasLower || prevType == 0 /* Tp.NonWord */ && type != 0 /* Tp.NonWord */) {
281
281
  if (chars[byWordTo] == next || (folded[byWordTo] == next && (byWordFolded = true)))
282
282
  byWord[byWordTo++] = i;
283
283
  else if (byWord.length)
@@ -287,17 +287,17 @@ class FuzzyMatcher {
287
287
  i += codePointSize(next);
288
288
  }
289
289
  if (byWordTo == len && byWord[0] == 0 && wordAdjacent)
290
- return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0), byWord, word);
290
+ return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0), byWord, word);
291
291
  if (adjacentTo == len && adjacentStart == 0)
292
- return [-200 /* CaseFold */ - word.length, 0, adjacentEnd];
292
+ return [-200 /* Penalty.CaseFold */ - word.length, 0, adjacentEnd];
293
293
  if (direct > -1)
294
- return [-700 /* NotStart */ - word.length, direct, direct + this.pattern.length];
294
+ return [-700 /* Penalty.NotStart */ - word.length, direct, direct + this.pattern.length];
295
295
  if (adjacentTo == len)
296
- return [-200 /* CaseFold */ + -700 /* NotStart */ - word.length, adjacentStart, adjacentEnd];
296
+ return [-200 /* Penalty.CaseFold */ + -700 /* Penalty.NotStart */ - word.length, adjacentStart, adjacentEnd];
297
297
  if (byWordTo == len)
298
- return this.result(-100 /* ByWord */ + (byWordFolded ? -200 /* CaseFold */ : 0) + -700 /* NotStart */ +
299
- (wordAdjacent ? 0 : -1100 /* Gap */), byWord, word);
300
- return chars.length == 2 ? null : this.result((any[0] ? -700 /* NotStart */ : 0) + -200 /* CaseFold */ + -1100 /* Gap */, any, word);
298
+ return this.result(-100 /* Penalty.ByWord */ + (byWordFolded ? -200 /* Penalty.CaseFold */ : 0) + -700 /* Penalty.NotStart */ +
299
+ (wordAdjacent ? 0 : -1100 /* Penalty.Gap */), byWord, word);
300
+ return chars.length == 2 ? null : this.result((any[0] ? -700 /* Penalty.NotStart */ : 0) + -200 /* Penalty.CaseFold */ + -1100 /* Penalty.Gap */, any, word);
301
301
  }
302
302
  result(score, positions, word) {
303
303
  let result = [score - word.length], i = 1;
@@ -443,7 +443,7 @@ class CompletionTooltip {
443
443
  }
444
444
  updateSel() {
445
445
  let cState = this.view.state.field(this.stateField), open = cState.open;
446
- if (open.selected < this.range.from || open.selected >= this.range.to) {
446
+ if (open.selected > -1 && open.selected < this.range.from || open.selected >= this.range.to) {
447
447
  this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions);
448
448
  this.list.remove();
449
449
  this.list = this.dom.appendChild(this.createListBox(open.options, cState.id, this.range));
@@ -504,26 +504,47 @@ class CompletionTooltip {
504
504
  let sel = this.dom.querySelector("[aria-selected]");
505
505
  if (!sel || !this.info)
506
506
  return null;
507
+ let win = this.dom.ownerDocument.defaultView;
507
508
  let listRect = this.dom.getBoundingClientRect();
508
509
  let infoRect = this.info.getBoundingClientRect();
509
510
  let selRect = sel.getBoundingClientRect();
510
- if (selRect.top > Math.min(innerHeight, listRect.bottom) - 10 || selRect.bottom < Math.max(0, listRect.top) + 10)
511
+ if (selRect.top > Math.min(win.innerHeight, listRect.bottom) - 10 || selRect.bottom < Math.max(0, listRect.top) + 10)
511
512
  return null;
512
- let top = Math.max(0, Math.min(selRect.top, innerHeight - infoRect.height)) - listRect.top;
513
- let left = this.view.textDirection == Direction.RTL;
514
- let spaceLeft = listRect.left, spaceRight = innerWidth - listRect.right;
513
+ let rtl = this.view.textDirection == Direction.RTL, left = rtl, narrow = false, maxWidth;
514
+ let top = "", bottom = "";
515
+ let spaceLeft = listRect.left, spaceRight = win.innerWidth - listRect.right;
515
516
  if (left && spaceLeft < Math.min(infoRect.width, spaceRight))
516
517
  left = false;
517
518
  else if (!left && spaceRight < Math.min(infoRect.width, spaceLeft))
518
519
  left = true;
519
- return { top, left };
520
+ if (infoRect.width <= (left ? spaceLeft : spaceRight)) {
521
+ top = (Math.max(0, Math.min(selRect.top, win.innerHeight - infoRect.height)) - listRect.top) + "px";
522
+ maxWidth = Math.min(400 /* Info.Width */, left ? spaceLeft : spaceRight) + "px";
523
+ }
524
+ else {
525
+ narrow = true;
526
+ maxWidth = Math.min(400 /* Info.Width */, (rtl ? listRect.right : win.innerWidth - listRect.left) - 30 /* Info.Margin */) + "px";
527
+ let spaceBelow = win.innerHeight - listRect.bottom;
528
+ if (spaceBelow >= infoRect.height || spaceBelow > listRect.top) // Below the completion
529
+ top = (selRect.bottom - listRect.top) + "px";
530
+ else // Above it
531
+ bottom = (listRect.bottom - selRect.top) + "px";
532
+ }
533
+ return {
534
+ top, bottom, maxWidth,
535
+ class: narrow ? (rtl ? "left-narrow" : "right-narrow") : left ? "left" : "right",
536
+ };
520
537
  }
521
538
  positionInfo(pos) {
522
539
  if (this.info) {
523
- this.info.style.top = (pos ? pos.top : -1e6) + "px";
524
540
  if (pos) {
525
- this.info.classList.toggle("cm-completionInfo-left", pos.left);
526
- this.info.classList.toggle("cm-completionInfo-right", !pos.left);
541
+ this.info.style.top = pos.top;
542
+ this.info.style.bottom = pos.bottom;
543
+ this.info.style.maxWidth = pos.maxWidth;
544
+ this.info.className = "cm-tooltip cm-completionInfo cm-completionInfo-" + pos.class;
545
+ }
546
+ else {
547
+ this.info.style.top = "-1e6px";
527
548
  }
528
549
  }
529
550
  }
@@ -661,7 +682,7 @@ class CompletionState {
661
682
  state.languageDataAt("autocomplete", cur(state)).map(asSource);
662
683
  let active = sources.map(source => {
663
684
  let value = this.active.find(s => s.source == source) ||
664
- new ActiveSource(source, this.active.some(a => a.state != 0 /* Inactive */) ? 1 /* Pending */ : 0 /* Inactive */);
685
+ new ActiveSource(source, this.active.some(a => a.state != 0 /* State.Inactive */) ? 1 /* State.Pending */ : 0 /* State.Inactive */);
665
686
  return value.update(tr, conf);
666
687
  });
667
688
  if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
@@ -669,8 +690,8 @@ class CompletionState {
669
690
  let open = tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
670
691
  !sameResults(active, this.active) ? CompletionDialog.build(active, state, this.id, this.open, conf)
671
692
  : this.open && tr.docChanged ? this.open.map(tr.changes) : this.open;
672
- if (!open && active.every(a => a.state != 1 /* Pending */) && active.some(a => a.hasResult()))
673
- active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* Inactive */) : a);
693
+ if (!open && active.every(a => a.state != 1 /* State.Pending */) && active.some(a => a.hasResult()))
694
+ active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* State.Inactive */) : a);
674
695
  for (let effect of tr.effects)
675
696
  if (effect.is(setSelectedEffect))
676
697
  open = open && open.setSelected(effect.value, this.id);
@@ -724,13 +745,13 @@ class ActiveSource {
724
745
  value = value.handleUserEvent(tr, event, conf);
725
746
  else if (tr.docChanged)
726
747
  value = value.handleChange(tr);
727
- else if (tr.selection && value.state != 0 /* Inactive */)
728
- value = new ActiveSource(value.source, 0 /* Inactive */);
748
+ else if (tr.selection && value.state != 0 /* State.Inactive */)
749
+ value = new ActiveSource(value.source, 0 /* State.Inactive */);
729
750
  for (let effect of tr.effects) {
730
751
  if (effect.is(startCompletionEffect))
731
- value = new ActiveSource(value.source, 1 /* Pending */, effect.value ? cur(tr.state) : -1);
752
+ value = new ActiveSource(value.source, 1 /* State.Pending */, effect.value ? cur(tr.state) : -1);
732
753
  else if (effect.is(closeCompletionEffect))
733
- value = new ActiveSource(value.source, 0 /* Inactive */);
754
+ value = new ActiveSource(value.source, 0 /* State.Inactive */);
734
755
  else if (effect.is(setActiveEffect))
735
756
  for (let active of effect.value)
736
757
  if (active.source == value.source)
@@ -739,10 +760,10 @@ class ActiveSource {
739
760
  return value;
740
761
  }
741
762
  handleUserEvent(tr, type, conf) {
742
- return type == "delete" || !conf.activateOnTyping ? this.map(tr.changes) : new ActiveSource(this.source, 1 /* Pending */);
763
+ return type == "delete" || !conf.activateOnTyping ? this.map(tr.changes) : new ActiveSource(this.source, 1 /* State.Pending */);
743
764
  }
744
765
  handleChange(tr) {
745
- return tr.changes.touchesRange(cur(tr.startState)) ? new ActiveSource(this.source, 0 /* Inactive */) : this.map(tr.changes);
766
+ return tr.changes.touchesRange(cur(tr.startState)) ? new ActiveSource(this.source, 0 /* State.Inactive */) : this.map(tr.changes);
746
767
  }
747
768
  map(changes) {
748
769
  return changes.empty || this.explicitPos < 0 ? this : new ActiveSource(this.source, this.state, changes.mapPos(this.explicitPos));
@@ -750,7 +771,7 @@ class ActiveSource {
750
771
  }
751
772
  class ActiveResult extends ActiveSource {
752
773
  constructor(source, explicitPos, result, from, to) {
753
- super(source, 2 /* Result */, explicitPos);
774
+ super(source, 2 /* State.Result */, explicitPos);
754
775
  this.result = result;
755
776
  this.from = from;
756
777
  this.to = to;
@@ -763,17 +784,17 @@ class ActiveResult extends ActiveSource {
763
784
  if ((this.explicitPos < 0 ? pos <= from : pos < this.from) ||
764
785
  pos > to ||
765
786
  type == "delete" && cur(tr.startState) == this.from)
766
- return new ActiveSource(this.source, type == "input" && conf.activateOnTyping ? 1 /* Pending */ : 0 /* Inactive */);
787
+ return new ActiveSource(this.source, type == "input" && conf.activateOnTyping ? 1 /* State.Pending */ : 0 /* State.Inactive */);
767
788
  let explicitPos = this.explicitPos < 0 ? -1 : tr.changes.mapPos(this.explicitPos), updated;
768
789
  if (checkValid(this.result.validFor, tr.state, from, to))
769
790
  return new ActiveResult(this.source, explicitPos, this.result, from, to);
770
791
  if (this.result.update &&
771
792
  (updated = this.result.update(this.result, from, to, new CompletionContext(tr.state, pos, explicitPos >= 0))))
772
793
  return new ActiveResult(this.source, explicitPos, updated, updated.from, (_a = updated.to) !== null && _a !== void 0 ? _a : cur(tr.state));
773
- return new ActiveSource(this.source, 1 /* Pending */, explicitPos);
794
+ return new ActiveSource(this.source, 1 /* State.Pending */, explicitPos);
774
795
  }
775
796
  handleChange(tr) {
776
- return tr.changes.touchesRange(this.from, this.to) ? new ActiveSource(this.source, 0 /* Inactive */) : this.map(tr.changes);
797
+ return tr.changes.touchesRange(this.from, this.to) ? new ActiveSource(this.source, 0 /* State.Inactive */) : this.map(tr.changes);
777
798
  }
778
799
  map(mapping) {
779
800
  return mapping.empty ? this :
@@ -851,7 +872,7 @@ Close the currently active completion.
851
872
  */
852
873
  const closeCompletion = (view) => {
853
874
  let cState = view.state.field(completionState, false);
854
- if (!cState || !cState.active.some(a => a.state != 0 /* Inactive */))
875
+ if (!cState || !cState.active.some(a => a.state != 0 /* State.Inactive */))
855
876
  return false;
856
877
  view.dispatch({ effects: closeCompletionEffect.of(null) });
857
878
  return true;
@@ -874,9 +895,9 @@ const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
874
895
  this.debounceUpdate = -1;
875
896
  this.running = [];
876
897
  this.debounceAccept = -1;
877
- this.composing = 0 /* None */;
898
+ this.composing = 0 /* CompositionState.None */;
878
899
  for (let active of view.state.field(completionState).active)
879
- if (active.state == 1 /* Pending */)
900
+ if (active.state == 1 /* State.Pending */)
880
901
  this.startQuery(active);
881
902
  }
882
903
  update(update) {
@@ -907,21 +928,21 @@ const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
907
928
  }
908
929
  if (this.debounceUpdate > -1)
909
930
  clearTimeout(this.debounceUpdate);
910
- this.debounceUpdate = cState.active.some(a => a.state == 1 /* Pending */ && !this.running.some(q => q.active.source == a.source))
931
+ this.debounceUpdate = cState.active.some(a => a.state == 1 /* State.Pending */ && !this.running.some(q => q.active.source == a.source))
911
932
  ? setTimeout(() => this.startUpdate(), DebounceTime) : -1;
912
- if (this.composing != 0 /* None */)
933
+ if (this.composing != 0 /* CompositionState.None */)
913
934
  for (let tr of update.transactions) {
914
935
  if (getUserEvent(tr) == "input")
915
- this.composing = 2 /* Changed */;
916
- else if (this.composing == 2 /* Changed */ && tr.selection)
917
- this.composing = 3 /* ChangedAndMoved */;
936
+ this.composing = 2 /* CompositionState.Changed */;
937
+ else if (this.composing == 2 /* CompositionState.Changed */ && tr.selection)
938
+ this.composing = 3 /* CompositionState.ChangedAndMoved */;
918
939
  }
919
940
  }
920
941
  startUpdate() {
921
942
  this.debounceUpdate = -1;
922
943
  let { state } = this.view, cState = state.field(completionState);
923
944
  for (let active of cState.active) {
924
- if (active.state == 1 /* Pending */ && !this.running.some(r => r.active.source == active.source))
945
+ if (active.state == 1 /* State.Pending */ && !this.running.some(r => r.active.source == active.source))
925
946
  this.startQuery(active);
926
947
  }
927
948
  }
@@ -972,14 +993,14 @@ const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
972
993
  }
973
994
  }
974
995
  let current = this.view.state.field(completionState).active.find(a => a.source == query.active.source);
975
- if (current && current.state == 1 /* Pending */) {
996
+ if (current && current.state == 1 /* State.Pending */) {
976
997
  if (query.done == null) {
977
998
  // Explicitly failed. Should clear the pending status if it
978
999
  // hasn't been re-set in the meantime.
979
- let active = new ActiveSource(query.active.source, 0 /* Inactive */);
1000
+ let active = new ActiveSource(query.active.source, 0 /* State.Inactive */);
980
1001
  for (let tr of query.updates)
981
1002
  active = active.update(tr, conf);
982
- if (active.state != 1 /* Pending */)
1003
+ if (active.state != 1 /* State.Pending */)
983
1004
  updated.push(active);
984
1005
  }
985
1006
  else {
@@ -999,15 +1020,15 @@ const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
999
1020
  this.view.dispatch({ effects: closeCompletionEffect.of(null) });
1000
1021
  },
1001
1022
  compositionstart() {
1002
- this.composing = 1 /* Started */;
1023
+ this.composing = 1 /* CompositionState.Started */;
1003
1024
  },
1004
1025
  compositionend() {
1005
- if (this.composing == 3 /* ChangedAndMoved */) {
1026
+ if (this.composing == 3 /* CompositionState.ChangedAndMoved */) {
1006
1027
  // Safari fires compositionend events synchronously, possibly
1007
1028
  // from inside an update, so dispatch asynchronously to avoid reentrancy
1008
1029
  setTimeout(() => this.view.dispatch({ effects: startCompletionEffect.of(false) }), 20);
1009
1030
  }
1010
- this.composing = 0 /* None */;
1031
+ this.composing = 0 /* CompositionState.None */;
1011
1032
  }
1012
1033
  }
1013
1034
  });
@@ -1052,10 +1073,13 @@ const baseTheme = /*@__PURE__*/EditorView.baseTheme({
1052
1073
  position: "absolute",
1053
1074
  padding: "3px 9px",
1054
1075
  width: "max-content",
1055
- maxWidth: "300px",
1076
+ maxWidth: `${400 /* Info.Width */}px`,
1077
+ boxSizing: "border-box"
1056
1078
  },
1057
1079
  ".cm-completionInfo.cm-completionInfo-left": { right: "100%" },
1058
1080
  ".cm-completionInfo.cm-completionInfo-right": { left: "100%" },
1081
+ ".cm-completionInfo.cm-completionInfo-left-narrow": { right: `${30 /* Info.Margin */}px` },
1082
+ ".cm-completionInfo.cm-completionInfo-right-narrow": { left: `${30 /* Info.Margin */}px` },
1059
1083
  "&light .cm-snippetField": { backgroundColor: "#00000022" },
1060
1084
  "&dark .cm-snippetField": { backgroundColor: "#ffffff22" },
1061
1085
  ".cm-snippetFieldPosition": {
@@ -1390,7 +1414,7 @@ function storeWords(doc, wordRE, result, seen, ignoreAt) {
1390
1414
  if (!seen[m[0]] && pos + m.index != ignoreAt) {
1391
1415
  result.push({ type: "text", label: m[0] });
1392
1416
  seen[m[0]] = true;
1393
- if (result.length >= 2000 /* MaxList */)
1417
+ if (result.length >= 2000 /* C.MaxList */)
1394
1418
  return;
1395
1419
  }
1396
1420
  }
@@ -1398,7 +1422,7 @@ function storeWords(doc, wordRE, result, seen, ignoreAt) {
1398
1422
  }
1399
1423
  }
1400
1424
  function collectWords(doc, cache, wordRE, to, ignoreAt) {
1401
- let big = doc.length >= 1000 /* MinCacheLen */;
1425
+ let big = doc.length >= 1000 /* C.MinCacheLen */;
1402
1426
  let cached = big && cache.get(doc);
1403
1427
  if (cached)
1404
1428
  return cached;
@@ -1406,7 +1430,7 @@ function collectWords(doc, cache, wordRE, to, ignoreAt) {
1406
1430
  if (doc.children) {
1407
1431
  let pos = 0;
1408
1432
  for (let ch of doc.children) {
1409
- if (ch.length >= 1000 /* MinCacheLen */) {
1433
+ if (ch.length >= 1000 /* C.MinCacheLen */) {
1410
1434
  for (let c of collectWords(ch, cache, wordRE, to - pos, ignoreAt - pos)) {
1411
1435
  if (!seen[c.label]) {
1412
1436
  seen[c.label] = true;
@@ -1423,7 +1447,7 @@ function collectWords(doc, cache, wordRE, to, ignoreAt) {
1423
1447
  else {
1424
1448
  storeWords(doc, wordRE, result, seen, ignoreAt);
1425
1449
  }
1426
- if (big && result.length < 2000 /* MaxList */)
1450
+ if (big && result.length < 2000 /* C.MaxList */)
1427
1451
  cache.set(doc, result);
1428
1452
  return result;
1429
1453
  }
@@ -1439,7 +1463,7 @@ const completeAnyWord = context => {
1439
1463
  if (!token && !context.explicit)
1440
1464
  return null;
1441
1465
  let from = token ? token.from : context.pos;
1442
- let options = collectWords(context.state.doc, wordCache(wordChars), re, 50000 /* Range */, from);
1466
+ let options = collectWords(context.state.doc, wordCache(wordChars), re, 50000 /* C.Range */, from);
1443
1467
  return { from, options, validFor: mapRE(re, s => "^" + s) };
1444
1468
  };
1445
1469
 
@@ -1528,14 +1552,13 @@ const deleteBracketPair = ({ state, dispatch }) => {
1528
1552
  for (let token of tokens) {
1529
1553
  if (token == before && nextChar(state.doc, range.head) == closing(codePointAt(token, 0)))
1530
1554
  return { changes: { from: range.head - token.length, to: range.head + token.length },
1531
- range: EditorSelection.cursor(range.head - token.length),
1532
- userEvent: "delete.backward" };
1555
+ range: EditorSelection.cursor(range.head - token.length) };
1533
1556
  }
1534
1557
  }
1535
1558
  return { range: dont = range };
1536
1559
  });
1537
1560
  if (!dont)
1538
- dispatch(state.update(changes, { scrollIntoView: true }));
1561
+ dispatch(state.update(changes, { scrollIntoView: true, userEvent: "delete.backward" }));
1539
1562
  return !dont;
1540
1563
  };
1541
1564
  /**
@@ -1721,8 +1744,8 @@ returns `null`.
1721
1744
  */
1722
1745
  function completionStatus(state) {
1723
1746
  let cState = state.field(completionState, false);
1724
- return cState && cState.active.some(a => a.state == 1 /* Pending */) ? "pending"
1725
- : cState && cState.active.some(a => a.state != 0 /* Inactive */) ? "active" : null;
1747
+ return cState && cState.active.some(a => a.state == 1 /* State.Pending */) ? "pending"
1748
+ : cState && cState.active.some(a => a.state != 0 /* State.Inactive */) ? "active" : null;
1726
1749
  }
1727
1750
  const completionArrayCache = /*@__PURE__*/new WeakMap;
1728
1751
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/autocomplete",
3
- "version": "6.1.0",
3
+ "version": "6.1.1",
4
4
  "description": "Autocompletion for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",