maybe improve text match

This commit is contained in:
Philipp Kühn 2021-01-15 09:55:15 +01:00
parent a5d28a0184
commit 3d28386e11

View File

@ -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)