@codemirror/autocomplete 6.18.1 → 6.18.2
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 +6 -0
- package/dist/index.cjs +16 -11
- package/dist/index.js +16 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -816,12 +816,12 @@ class CompletionDialog {
|
|
|
816
816
|
return selected == this.selected || selected >= this.options.length ? this
|
|
817
817
|
: new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected, this.disabled);
|
|
818
818
|
}
|
|
819
|
-
static build(active, state, id, prev, conf) {
|
|
819
|
+
static build(active, state, id, prev, conf, didSetActive) {
|
|
820
|
+
if (prev && !didSetActive && active.some(s => s.state == 1 /* State.Pending */))
|
|
821
|
+
return prev.setDisabled();
|
|
820
822
|
let options = sortOptions(active, state);
|
|
821
|
-
if (!options.length)
|
|
822
|
-
return prev && active.some(a => a.state == 1 /* State.Pending */) ?
|
|
823
|
-
new CompletionDialog(prev.options, prev.attrs, prev.tooltip, prev.timestamp, prev.selected, true) : null;
|
|
824
|
-
}
|
|
823
|
+
if (!options.length)
|
|
824
|
+
return prev && active.some(a => a.state == 1 /* State.Pending */) ? prev.setDisabled() : null;
|
|
825
825
|
let selected = state.facet(completionConfig).selectOnOpen ? 0 : -1;
|
|
826
826
|
if (prev && prev.selected != selected && prev.selected != -1) {
|
|
827
827
|
let selectedValue = prev.options[prev.selected].completion;
|
|
@@ -840,6 +840,9 @@ class CompletionDialog {
|
|
|
840
840
|
map(changes) {
|
|
841
841
|
return new CompletionDialog(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), { pos: changes.mapPos(this.tooltip.pos) }), this.timestamp, this.selected, this.disabled);
|
|
842
842
|
}
|
|
843
|
+
setDisabled() {
|
|
844
|
+
return new CompletionDialog(this.options, this.attrs, this.tooltip, this.timestamp, this.selected, true);
|
|
845
|
+
}
|
|
843
846
|
}
|
|
844
847
|
class CompletionState {
|
|
845
848
|
constructor(active, id, open) {
|
|
@@ -861,12 +864,12 @@ class CompletionState {
|
|
|
861
864
|
});
|
|
862
865
|
if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
|
|
863
866
|
active = this.active;
|
|
864
|
-
let open = this.open;
|
|
867
|
+
let open = this.open, didSet = tr.effects.some(e => e.is(setActiveEffect));
|
|
865
868
|
if (open && tr.docChanged)
|
|
866
869
|
open = open.map(tr.changes);
|
|
867
870
|
if (tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
|
|
868
|
-
!sameResults(active, this.active))
|
|
869
|
-
open = CompletionDialog.build(active, state, this.id, open, conf);
|
|
871
|
+
!sameResults(active, this.active) || didSet)
|
|
872
|
+
open = CompletionDialog.build(active, state, this.id, open, conf, didSet);
|
|
870
873
|
else if (open && open.disabled && !active.some(a => a.state == 1 /* State.Pending */))
|
|
871
874
|
open = null;
|
|
872
875
|
if (!open && active.every(a => a.state != 1 /* State.Pending */) && active.some(a => a.hasResult()))
|
|
@@ -1158,6 +1161,8 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
|
|
|
1158
1161
|
if (active.state == 1 /* State.Pending */ && !this.running.some(r => r.active.source == active.source))
|
|
1159
1162
|
this.startQuery(active);
|
|
1160
1163
|
}
|
|
1164
|
+
if (this.running.length && cState.open && cState.open.disabled)
|
|
1165
|
+
this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime);
|
|
1161
1166
|
}
|
|
1162
1167
|
startQuery(active) {
|
|
1163
1168
|
let { state } = this.view, pos = cur(state);
|
|
@@ -1188,7 +1193,7 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
|
|
|
1188
1193
|
clearTimeout(this.debounceAccept);
|
|
1189
1194
|
this.debounceAccept = -1;
|
|
1190
1195
|
let updated = [];
|
|
1191
|
-
let conf = this.view.state.facet(completionConfig);
|
|
1196
|
+
let conf = this.view.state.facet(completionConfig), cState = this.view.state.field(completionState);
|
|
1192
1197
|
for (let i = 0; i < this.running.length; i++) {
|
|
1193
1198
|
let query = this.running[i];
|
|
1194
1199
|
if (query.done === undefined)
|
|
@@ -1205,7 +1210,7 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
|
|
|
1205
1210
|
continue;
|
|
1206
1211
|
}
|
|
1207
1212
|
}
|
|
1208
|
-
let current =
|
|
1213
|
+
let current = cState.active.find(a => a.source == query.active.source);
|
|
1209
1214
|
if (current && current.state == 1 /* State.Pending */) {
|
|
1210
1215
|
if (query.done == null) {
|
|
1211
1216
|
// Explicitly failed. Should clear the pending status if it
|
|
@@ -1222,7 +1227,7 @@ const completionPlugin = view.ViewPlugin.fromClass(class {
|
|
|
1222
1227
|
}
|
|
1223
1228
|
}
|
|
1224
1229
|
}
|
|
1225
|
-
if (updated.length)
|
|
1230
|
+
if (updated.length || cState.open && cState.open.disabled)
|
|
1226
1231
|
this.view.dispatch({ effects: setActiveEffect.of(updated) });
|
|
1227
1232
|
}
|
|
1228
1233
|
}, {
|
package/dist/index.js
CHANGED
|
@@ -814,12 +814,12 @@ class CompletionDialog {
|
|
|
814
814
|
return selected == this.selected || selected >= this.options.length ? this
|
|
815
815
|
: new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected, this.disabled);
|
|
816
816
|
}
|
|
817
|
-
static build(active, state, id, prev, conf) {
|
|
817
|
+
static build(active, state, id, prev, conf, didSetActive) {
|
|
818
|
+
if (prev && !didSetActive && active.some(s => s.state == 1 /* State.Pending */))
|
|
819
|
+
return prev.setDisabled();
|
|
818
820
|
let options = sortOptions(active, state);
|
|
819
|
-
if (!options.length)
|
|
820
|
-
return prev && active.some(a => a.state == 1 /* State.Pending */) ?
|
|
821
|
-
new CompletionDialog(prev.options, prev.attrs, prev.tooltip, prev.timestamp, prev.selected, true) : null;
|
|
822
|
-
}
|
|
821
|
+
if (!options.length)
|
|
822
|
+
return prev && active.some(a => a.state == 1 /* State.Pending */) ? prev.setDisabled() : null;
|
|
823
823
|
let selected = state.facet(completionConfig).selectOnOpen ? 0 : -1;
|
|
824
824
|
if (prev && prev.selected != selected && prev.selected != -1) {
|
|
825
825
|
let selectedValue = prev.options[prev.selected].completion;
|
|
@@ -838,6 +838,9 @@ class CompletionDialog {
|
|
|
838
838
|
map(changes) {
|
|
839
839
|
return new CompletionDialog(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), { pos: changes.mapPos(this.tooltip.pos) }), this.timestamp, this.selected, this.disabled);
|
|
840
840
|
}
|
|
841
|
+
setDisabled() {
|
|
842
|
+
return new CompletionDialog(this.options, this.attrs, this.tooltip, this.timestamp, this.selected, true);
|
|
843
|
+
}
|
|
841
844
|
}
|
|
842
845
|
class CompletionState {
|
|
843
846
|
constructor(active, id, open) {
|
|
@@ -859,12 +862,12 @@ class CompletionState {
|
|
|
859
862
|
});
|
|
860
863
|
if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
|
|
861
864
|
active = this.active;
|
|
862
|
-
let open = this.open;
|
|
865
|
+
let open = this.open, didSet = tr.effects.some(e => e.is(setActiveEffect));
|
|
863
866
|
if (open && tr.docChanged)
|
|
864
867
|
open = open.map(tr.changes);
|
|
865
868
|
if (tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
|
|
866
|
-
!sameResults(active, this.active))
|
|
867
|
-
open = CompletionDialog.build(active, state, this.id, open, conf);
|
|
869
|
+
!sameResults(active, this.active) || didSet)
|
|
870
|
+
open = CompletionDialog.build(active, state, this.id, open, conf, didSet);
|
|
868
871
|
else if (open && open.disabled && !active.some(a => a.state == 1 /* State.Pending */))
|
|
869
872
|
open = null;
|
|
870
873
|
if (!open && active.every(a => a.state != 1 /* State.Pending */) && active.some(a => a.hasResult()))
|
|
@@ -1156,6 +1159,8 @@ const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
1156
1159
|
if (active.state == 1 /* State.Pending */ && !this.running.some(r => r.active.source == active.source))
|
|
1157
1160
|
this.startQuery(active);
|
|
1158
1161
|
}
|
|
1162
|
+
if (this.running.length && cState.open && cState.open.disabled)
|
|
1163
|
+
this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime);
|
|
1159
1164
|
}
|
|
1160
1165
|
startQuery(active) {
|
|
1161
1166
|
let { state } = this.view, pos = cur(state);
|
|
@@ -1186,7 +1191,7 @@ const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
1186
1191
|
clearTimeout(this.debounceAccept);
|
|
1187
1192
|
this.debounceAccept = -1;
|
|
1188
1193
|
let updated = [];
|
|
1189
|
-
let conf = this.view.state.facet(completionConfig);
|
|
1194
|
+
let conf = this.view.state.facet(completionConfig), cState = this.view.state.field(completionState);
|
|
1190
1195
|
for (let i = 0; i < this.running.length; i++) {
|
|
1191
1196
|
let query = this.running[i];
|
|
1192
1197
|
if (query.done === undefined)
|
|
@@ -1203,7 +1208,7 @@ const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
1203
1208
|
continue;
|
|
1204
1209
|
}
|
|
1205
1210
|
}
|
|
1206
|
-
let current =
|
|
1211
|
+
let current = cState.active.find(a => a.source == query.active.source);
|
|
1207
1212
|
if (current && current.state == 1 /* State.Pending */) {
|
|
1208
1213
|
if (query.done == null) {
|
|
1209
1214
|
// Explicitly failed. Should clear the pending status if it
|
|
@@ -1220,7 +1225,7 @@ const completionPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
1220
1225
|
}
|
|
1221
1226
|
}
|
|
1222
1227
|
}
|
|
1223
|
-
if (updated.length)
|
|
1228
|
+
if (updated.length || cState.open && cState.open.disabled)
|
|
1224
1229
|
this.view.dispatch({ effects: setActiveEffect.of(updated) });
|
|
1225
1230
|
}
|
|
1226
1231
|
}, {
|