maybe improve text match

This commit is contained in:
Philipp Kühn 2021-01-15 09:55:15 +01:00 committed by Hans Pagel
parent 44a026416b
commit 8e23627f61

View File

@ -30,7 +30,10 @@ function triggerCharacter(config: Trigger) {
// Lookup the boundaries of the current node // Lookup the boundaries of the current node
const textFrom = $position.before() 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') const text = $position.doc.textBetween(textFrom, textTo, '\0', '\0')
let match = regexp.exec(text) let match = regexp.exec(text)
@ -196,12 +199,11 @@ export function Suggestion({
} }
// Try to match against where our cursor currently is // Try to match against where our cursor currently is
const $position = selection.$from
const match = triggerCharacter({ const match = triggerCharacter({
char, char,
allowSpaces, allowSpaces,
startOfLine, startOfLine,
$position, $position: selection.$from,
}) })
const decorationId = (Math.random() + 1).toString(36).substr(2, 5) const decorationId = (Math.random() + 1).toString(36).substr(2, 5)