diff --git a/packages/suggestion/src/findSuggestionMatch.ts b/packages/suggestion/src/findSuggestionMatch.ts index 88b843c5..717a2eef 100644 --- a/packages/suggestion/src/findSuggestionMatch.ts +++ b/packages/suggestion/src/findSuggestionMatch.ts @@ -38,9 +38,9 @@ export function findSuggestionMatch(config: Trigger): SuggestionMatch { const textFrom = $position.before() const textTo = $position.pos const text = $position.doc.textBetween(textFrom, textTo, '\0', '\0') - const match = regexp.exec(text) + const match = Array.from(text.matchAll(regexp)).pop() - if (!match) { + if (!match || match.input === undefined || match.index === undefined) { return null } diff --git a/packages/suggestion/src/suggestion.ts b/packages/suggestion/src/suggestion.ts index f8eed1df..c7d0f576 100644 --- a/packages/suggestion/src/suggestion.ts +++ b/packages/suggestion/src/suggestion.ts @@ -101,16 +101,16 @@ export function Suggestion({ clientRect: () => decorationNode?.getBoundingClientRect() || null, } - if (handleStart) { - renderer?.onStart?.(props) + if (handleExit) { + renderer?.onExit?.(props) } if (handleChange) { renderer?.onUpdate?.(props) } - if (handleExit) { - renderer?.onExit?.(props) + if (handleStart) { + renderer?.onStart?.(props) } }, }