Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// Exited a suggestion
if (isExit(compare)) {
return findExitReason({ $pos, match: compare.prev, state });
}
if (isChange(compare)) {
return { change: createMatchWithReason({ match: compare.next, reason: ChangeReason.Text }) };
}
if (isMove(compare)) {
return {
change: createMatchWithReason({
match: compare.next,
reason: selectionEmpty(state) ? ChangeReason.Move : ChangeReason.SelectionInside,
}),
};
}
return value;
};
const findExitReason = ({
match,
state,
$pos,
}: SuggestStateMatchParams & EditorStateParams & ResolvedPosParams) => {
const { selection } = state;
const updatedPrev = recheckMatch({ match, state });
// Exit created a split
if (!updatedPrev || updatedPrev.queryText.full !== match.queryText.full) {
return createInsertReason({ prev: match, next: updatedPrev, state });
}
// Exit caused by a selection
if (!selectionEmpty(state) && (selection.from <= match.range.from || selection.to >= match.range.end)) {
return { exit: createMatchWithReason({ match, reason: ExitReason.SelectionOutside }) };
}
// Exit happened at the end of previous suggestion
if ($pos.pos > match.range.end) {
return { exit: createMatchWithReason({ match, reason: ExitReason.MoveEnd }) };
}
// Exit happened at the start of previous suggestion
if ($pos.pos <= match.range.from) {
return { exit: createMatchWithReason({ match, reason: ExitReason.MoveStart }) };
}
return {};
};