refactoring
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user