refactoring

This commit is contained in:
Philipp Kühn
2021-09-06 22:33:16 +02:00
parent 4dd0d6d4dc
commit 65e1a404e5

View File

@@ -47,11 +47,12 @@ export function findSuggestionMatch(config: Trigger): SuggestionMatch {
return null return null
} }
// JavaScript doesn't have lookbehinds; this hacks a check that first character is " " // JavaScript doesn't have lookbehinds. This hacks a check that first character
// or the line beginning // is a space or the start of the line
const matchPrefix = match.input.slice(Math.max(0, match.index - 1), match.index) 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 return null
} }