@codemirror/autocomplete
Advanced tools
Comparing version 0.18.6 to 0.18.7
@@ -0,1 +1,7 @@ | ||
## 0.18.7 (2021-06-14) | ||
### Bug fixes | ||
Don't treat continued completions when typing after an explicit completion as explicit. | ||
## 0.18.6 (2021-06-03) | ||
@@ -2,0 +8,0 @@ |
@@ -714,2 +714,3 @@ import { Facet, combineConfig, StateEffect, StateField, Transaction, Text, EditorSelection, Prec, CharCategory } from '@codemirror/state'; | ||
hasResult() { return false; } | ||
explicitAt(_pos) { return this.explicit; } | ||
update(tr, conf) { | ||
@@ -743,4 +744,5 @@ let event = tr.annotation(Transaction.userEvent), value = this; | ||
class ActiveResult extends ActiveSource { | ||
constructor(source, explicit, result, from, to, span) { | ||
super(source, 2 /* Result */, explicit); | ||
constructor(source, explicitPos, result, from, to, span) { | ||
super(source, 2 /* Result */, explicitPos > -1); | ||
this.explicitPos = explicitPos; | ||
this.result = result; | ||
@@ -752,2 +754,6 @@ this.from = from; | ||
hasResult() { return true; } | ||
explicitAt(pos) { return this.explicitPos == pos; } | ||
mapExplicit(mapping) { | ||
return this.explicitPos < 0 ? -1 : mapping.mapPos(this.explicitPos); | ||
} | ||
handleUserEvent(tr, type, conf) { | ||
@@ -759,12 +765,10 @@ let from = tr.changes.mapPos(this.from), to = tr.changes.mapPos(this.to, 1); | ||
if (this.span && (from == to || this.span.test(tr.state.sliceDoc(from, to)))) | ||
return new ActiveResult(this.source, this.explicit, this.result, from, to, this.span); | ||
return new ActiveSource(this.source, 1 /* Pending */, this.explicit); | ||
return new ActiveResult(this.source, this.mapExplicit(tr.changes), this.result, from, to, this.span); | ||
return new ActiveSource(this.source, 1 /* Pending */, false); | ||
} | ||
handleChange(tr) { | ||
return tr.changes.touchesRange(this.from, this.to) | ||
? new ActiveSource(this.source, 0 /* Inactive */, false) | ||
: new ActiveResult(this.source, this.explicit, this.result, tr.changes.mapPos(this.from), tr.changes.mapPos(this.to, 1), this.span); | ||
return tr.changes.touchesRange(this.from, this.to) ? new ActiveSource(this.source, 0 /* Inactive */, false) : this.map(tr.changes); | ||
} | ||
map(mapping) { | ||
return new ActiveResult(this.source, this.explicit, this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1), this.span); | ||
return new ActiveResult(this.source, this.mapExplicit(mapping), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1), this.span); | ||
} | ||
@@ -911,3 +915,3 @@ } | ||
let { state } = this.view, pos = cur(state); | ||
let context = new CompletionContext(state, pos, active.explicit); | ||
let context = new CompletionContext(state, pos, active.explicitAt(pos)); | ||
let pending = new RunningQuery(active.source, context); | ||
@@ -946,3 +950,3 @@ this.running.push(pending); | ||
if (query.done) { | ||
let active = new ActiveResult(query.source, query.context.explicit, query.done, query.done.from, (_a = query.done.to) !== null && _a !== void 0 ? _a : cur(query.updates.length ? query.updates[0].startState : this.view.state), query.done.span ? ensureAnchor(query.done.span, true) : null); | ||
let active = new ActiveResult(query.source, query.context.explicit ? query.context.pos : -1, query.done, query.done.from, (_a = query.done.to) !== null && _a !== void 0 ? _a : cur(query.updates.length ? query.updates[0].startState : this.view.state), query.done.span ? ensureAnchor(query.done.span, true) : null); | ||
// Replay the transactions that happened since the start of | ||
@@ -949,0 +953,0 @@ // the request and see if that preserves the result |
{ | ||
"name": "@codemirror/autocomplete", | ||
"version": "0.18.6", | ||
"version": "0.18.7", | ||
"description": "Autocompletion for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124937
2900