From aef0acf53da5b5c60d824eb401392e177a70f2b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Sun, 7 Feb 2021 20:00:13 +0100 Subject: [PATCH] fix bug in suggestion extension, fix #143 --- packages/suggestion/src/findSuggestionMatch.ts | 4 ++-- packages/suggestion/src/suggestion.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) 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) } }, }