diff --git a/src/state.ts b/src/state.ts index 3d14a43..6d52eaf 100644 --- a/src/state.ts +++ b/src/state.ts @@ -257,7 +257,7 @@ export class ActiveResult extends ActiveSource { type == "delete" && cur(tr.startState) == this.from) return new ActiveSource(this.source, type == "input" && conf.activateOnTyping ? State.Pending : State.Inactive) let explicitPos = this.explicitPos < 0 ? -1 : tr.changes.mapPos(this.explicitPos) - if (checkValid(result.validFor, tr.state, from, to)) + if (checkValid(result.validFor, tr, from, to)) return new ActiveResult(this.source, explicitPos, result, from, to) if (result.update && (result = result.update(result, from, to, new CompletionContext(tr.state, pos, explicitPos >= 0)))) @@ -279,10 +279,10 @@ export class ActiveResult extends ActiveSource { } function checkValid(validFor: undefined | RegExp | ((text: string, from: number, to: number, state: EditorState) => boolean), - state: EditorState, from: number, to: number) { - if (!validFor) return false - let text = state.sliceDoc(from, to) - return typeof validFor == "function" ? validFor(text, from, to, state) : ensureAnchor(validFor, true).test(text) + tr: Transaction, from: number, to: number) { + if (!validFor || tr.isUserEvent("input.complete")) return false + let text = tr.state.sliceDoc(from, to) + return typeof validFor == "function" ? validFor(text, from, to, tr.state) : ensureAnchor(validFor, true).test(text) } export const setActiveEffect = StateEffect.define({