Escape Suggestion trigger char

This commit is contained in:
Ivan
2018-12-07 21:05:10 +03:00
committed by GitHub
parent 19202f25f0
commit fe6b1bee2d

View File

@@ -11,11 +11,12 @@ function triggerCharacter({
return $position => {
// Matching expressions used for later
const suffix = new RegExp(`\\s${char}$`)
const escapedChar = `\\${char}`
const suffix = new RegExp(`\\s${escapedChar}$`)
const prefix = startOfLine ? '^' : ''
const regexp = allowSpaces
? new RegExp(`${prefix}${char}.*?(?=\\s${char}|$)`, 'gm')
: new RegExp(`${prefix}(?:^)?${char}[^\\s${char}]*`, 'gm')
? new RegExp(`${prefix}${escapedChar}.*?(?=\\s${escapedChar}|$)`, 'gm')
: new RegExp(`${prefix}(?:^)?${escapedChar}[^\\s${escapedChar}]*`, 'gm')
// Lookup the boundaries of the current node
const textFrom = $position.before()