From 3d28386e11468a1c1ff9c97f1f39c79662821120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 15 Jan 2021 09:55:15 +0100 Subject: [PATCH] maybe improve text match --- packages/suggestion/src/suggestion.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/suggestion/src/suggestion.ts b/packages/suggestion/src/suggestion.ts index 9300d7c5..4aa765b5 100644 --- a/packages/suggestion/src/suggestion.ts +++ b/packages/suggestion/src/suggestion.ts @@ -30,7 +30,10 @@ function triggerCharacter(config: Trigger) { // Lookup the boundaries of the current node const textFrom = $position.before() - const textTo = $position.end() + + // Only look up to the cursor, old behavior: textTo = $position.end() + const textTo = $position.pos + const text = $position.doc.textBetween(textFrom, textTo, '\0', '\0') let match = regexp.exec(text) @@ -196,12 +199,11 @@ export function Suggestion({ } // Try to match against where our cursor currently is - const $position = selection.$from const match = triggerCharacter({ char, allowSpaces, startOfLine, - $position, + $position: selection.$from, }) const decorationId = (Math.random() + 1).toString(36).substr(2, 5)