Fallback for old safari

This commit is contained in:
Cohee 2024-05-14 23:43:17 +03:00
parent 1dec93de8a
commit f0016b5368
1 changed files with 9 additions and 1 deletions

View File

@ -50,6 +50,14 @@ export class SlashCommandAutoCompleteNameResult extends AutoCompleteNameResult {
}
getNamedArgumentAt(text, index, isSelect) {
function getSplitRegex() {
try {
return new RegExp('(?<==)');
} catch {
// For browsers that don't support lookbehind
return new RegExp('=(.*)');
}
}
const notProvidedNamedArguments = this.executor.command.namedArgumentList.filter(arg=>!this.executor.namedArgumentList.find(it=>it.name == arg.name));
let name;
let value;
@ -62,7 +70,7 @@ export class SlashCommandAutoCompleteNameResult extends AutoCompleteNameResult {
// cursor is somewhere within the named arguments (including final space)
argAssign = this.executor.namedArgumentList.find(it=>it.start <= index && it.end >= index);
if (argAssign) {
const [argName, ...v] = text.slice(argAssign.start, index).split(/(?<==)/);
const [argName, ...v] = text.slice(argAssign.start, index).split(getSplitRegex());
name = argName;
value = v.join('');
start = argAssign.start;