mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
add autocomplete for multiple unnamed args
This commit is contained in:
@ -90,8 +90,8 @@ export class SlashCommandAutoCompleteNameResult extends AutoCompleteNameResult {
|
|||||||
}
|
}
|
||||||
} else if (unamedArgLength > 0 && index >= this.executor.startUnnamedArgs && index <= this.executor.endUnnamedArgs) {
|
} else if (unamedArgLength > 0 && index >= this.executor.startUnnamedArgs && index <= this.executor.endUnnamedArgs) {
|
||||||
// cursor is somewhere within the unnamed arguments
|
// cursor is somewhere within the unnamed arguments
|
||||||
//TODO if index is in first array item and that is a string, treat it as an unfinished named arg
|
// if index is in first array item and that is a string, treat it as an unfinished named arg
|
||||||
if (typeof this.executor.unnamedArgumentList[0].value == 'string') {
|
if (typeof this.executor.unnamedArgumentList[0]?.value == 'string') {
|
||||||
if (index <= this.executor.startUnnamedArgs + this.executor.unnamedArgumentList[0].value.length) {
|
if (index <= this.executor.startUnnamedArgs + this.executor.unnamedArgumentList[0].value.length) {
|
||||||
name = this.executor.unnamedArgumentList[0].value.slice(0, index - this.executor.startUnnamedArgs);
|
name = this.executor.unnamedArgumentList[0].value.slice(0, index - this.executor.startUnnamedArgs);
|
||||||
start = this.executor.startUnnamedArgs;
|
start = this.executor.startUnnamedArgs;
|
||||||
@ -154,6 +154,9 @@ export class SlashCommandAutoCompleteNameResult extends AutoCompleteNameResult {
|
|||||||
if (idx > -1) {
|
if (idx > -1) {
|
||||||
argAssign = this.executor.unnamedArgumentList[idx];
|
argAssign = this.executor.unnamedArgumentList[idx];
|
||||||
cmdArg = this.executor.command.unnamedArgumentList[idx];
|
cmdArg = this.executor.command.unnamedArgumentList[idx];
|
||||||
|
if (cmdArg === undefined && this.executor.command.unnamedArgumentList.slice(-1)[0].acceptsMultiple) {
|
||||||
|
cmdArg = this.executor.command.unnamedArgumentList.slice(-1)[0];
|
||||||
|
}
|
||||||
const enumList = cmdArg?.enumProvider?.(this.executor, this.scope) ?? cmdArg?.enumList;
|
const enumList = cmdArg?.enumProvider?.(this.executor, this.scope) ?? cmdArg?.enumList;
|
||||||
if (cmdArg && enumList.length > 0) {
|
if (cmdArg && enumList.length > 0) {
|
||||||
value = argAssign.value.toString().slice(0, index - argAssign.start);
|
value = argAssign.value.toString().slice(0, index - argAssign.start);
|
||||||
@ -165,6 +168,9 @@ export class SlashCommandAutoCompleteNameResult extends AutoCompleteNameResult {
|
|||||||
value = '';
|
value = '';
|
||||||
start = index;
|
start = index;
|
||||||
cmdArg = notProvidedArguments[0];
|
cmdArg = notProvidedArguments[0];
|
||||||
|
if (cmdArg === undefined && this.executor.command.unnamedArgumentList.slice(-1)[0].acceptsMultiple) {
|
||||||
|
cmdArg = this.executor.command.unnamedArgumentList.slice(-1)[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -757,7 +757,7 @@ export class SlashCommandParser {
|
|||||||
this.discardWhitespace();
|
this.discardWhitespace();
|
||||||
}
|
}
|
||||||
this.discardWhitespace();
|
this.discardWhitespace();
|
||||||
cmd.startUnnamedArgs = this.index;
|
cmd.startUnnamedArgs = this.index - /\s(\s*)$/s.exec(this.behind)[1]?.length ?? 0;
|
||||||
cmd.endUnnamedArgs = this.index;
|
cmd.endUnnamedArgs = this.index;
|
||||||
if (this.testUnnamedArgument()) {
|
if (this.testUnnamedArgument()) {
|
||||||
cmd.unnamedArgumentList = this.parseUnnamedArgument(cmd.command?.unnamedArgumentList?.length && cmd?.command?.splitUnnamedArgument);
|
cmd.unnamedArgumentList = this.parseUnnamedArgument(cmd.command?.unnamedArgumentList?.length && cmd?.command?.splitUnnamedArgument);
|
||||||
|
Reference in New Issue
Block a user