Parser followup (#2377)

* set pipe to empty string on empty closure

* fix missing parser flags and scope

* add closure serializing

* add enum provider function to slash command arguments

* add enum providers for /bg, /ask, and /go

* fix index out of bounds returning undefined

* keep whitespace as is in mixed unnamed args (string+closure)

* add _hasUnnamedArgument to named arguments dictionary

* allow /var key=x retrieval

* add enum provider to /tag-add

* fix typo (case)

* add option to make enum matching optional

* add executor to enum provider

* change /tag-add enum provider to only show tags not already assigned

* add enum provider to /tag-remove

* fix name enum provider excluding groups

* remove void from slash command callback return types

* Lint undefined and null pipes

* enable pointer events in chat autocomplete

* fix type hint

---------

Co-authored-by: LenAnderson <Anderson.Len@outlook.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
Len
2024-06-14 17:48:41 -04:00
committed by GitHub
parent cef65a17f9
commit 5cb319771d
18 changed files with 314 additions and 82 deletions

View File

@ -598,6 +598,7 @@ export class SlashCommandParser {
this.closureIndex.push(closureIndexEntry);
let injectPipe = true;
if (!isRoot) this.take(2); // discard opening {:
const textStart = this.index;
let closure = new SlashCommandClosure(this.scope);
closure.abortController = this.abortController;
this.scope = closure.scope;
@ -638,13 +639,13 @@ export class SlashCommandParser {
}
this.discardWhitespace(); // discard further whitespace
}
closure.rawText = this.text.slice(textStart, this.index);
if (!isRoot) this.take(2); // discard closing :}
if (this.testSymbol('()')) {
this.take(2); // discard ()
closure.executeNow = true;
}
closureIndexEntry.end = this.index - 1;
this.discardWhitespace(); // discard trailing whitespace
this.scope = closure.scope.parent;
return closure;
}
@ -820,9 +821,8 @@ export class SlashCommandParser {
if (this.testClosure()) {
isList = true;
if (value.length > 0) {
assignment.end = assignment.end - (value.length - value.trim().length);
this.indexMacros(this.index - value.length, value);
assignment.value = value.trim();
assignment.value = value;
listValues.push(assignment);
assignment = new SlashCommandUnnamedArgumentAssignment();
assignment.start = this.index;
@ -834,6 +834,7 @@ export class SlashCommandParser {
listValues.push(assignment);
assignment = new SlashCommandUnnamedArgumentAssignment();
assignment.start = this.index;
if (split) this.discardWhitespace();
} else if (split) {
if (this.testQuotedValue()) {
assignment.start = this.index;
@ -862,8 +863,8 @@ export class SlashCommandParser {
assignment.end = this.index;
}
}
if (isList && value.trim().length > 0) {
assignment.value = value.trim();
if (isList && value.length > 0) {
assignment.value = value;
listValues.push(assignment);
}
if (isList) {