diff --git a/packages/suggestion/src/findSuggestionMatch.ts b/packages/suggestion/src/findSuggestionMatch.ts index fcbc2087..fe7be2b9 100644 --- a/packages/suggestion/src/findSuggestionMatch.ts +++ b/packages/suggestion/src/findSuggestionMatch.ts @@ -47,11 +47,12 @@ export function findSuggestionMatch(config: Trigger): SuggestionMatch { return null } - // JavaScript doesn't have lookbehinds; this hacks a check that first character is " " - // or the line beginning + // JavaScript doesn't have lookbehinds. This hacks a check that first character + // is a space or the start of the line const matchPrefix = match.input.slice(Math.max(0, match.index - 1), match.index) + const matchPrefixIsSpace = /^[\s\0]?$/.test(matchPrefix) - if (prefixSpace && !/^[\s\0]?$/.test(matchPrefix)) { + if (prefixSpace && !matchPrefixIsSpace) { return null }