add some adjustments to make autocomplete work properly

some hint in there about "/:" would still be nice
This commit is contained in:
LenAnderson
2024-04-11 22:58:53 -04:00
parent 03916bceec
commit dd4c7a2521

View File

@ -175,9 +175,13 @@ export class SlashCommandParser {
console.warn(e); console.warn(e);
} }
index += 2; index += 2;
return this.commandIndex.filter(it=>it.start <= index && (it.end >= index || it.end == null)).slice(-1)[0] const executor = this.commandIndex
.filter(it=>it.start <= index && (it.end >= index || it.end == null))
.slice(-1)[0]
?? null ?? null
; ;
if (executor && executor.name == ':') return null;
return executor;
} }
take(length = 1, keep = false) { take(length = 1, keep = false) {
@ -259,7 +263,7 @@ export class SlashCommandParser {
} }
testRunShorthand() { testRunShorthand() {
return this.char == '/' && this.behind.slice(-1) != '\\' && this.ahead[0] == ':'; return this.ahead.length > 1 && this.char == '/' && this.behind.slice(-1) != '\\' && this.ahead[0] == ':' && this.ahead[1] != '}';
} }
testRunShorthandEnd() { testRunShorthandEnd() {
return this.testCommandEnd(); return this.testCommandEnd();
@ -267,7 +271,7 @@ export class SlashCommandParser {
parseRunShorthand() { parseRunShorthand() {
const start = this.index; const start = this.index;
const cmd = new SlashCommandExecutor(start); const cmd = new SlashCommandExecutor(start);
cmd.name = 'run'; cmd.name = ':';
cmd.value = ''; cmd.value = '';
cmd.command = this.commands[cmd.name]; cmd.command = this.commands[cmd.name];
this.commandIndex.push(cmd); this.commandIndex.push(cmd);
@ -293,7 +297,7 @@ export class SlashCommandParser {
} }
testCommand() { testCommand() {
return this.char == '/' && this.behind.slice(-1) != '\\' && !['/', '#'].includes(this.ahead[0]); return this.char == '/' && this.behind.slice(-1) != '\\' && !['/', '#'].includes(this.ahead[0]) && !(this.ahead[0] == ':' && this.ahead[1] != '}');
} }
testCommandEnd() { testCommandEnd() {
return this.testClosureEnd() || this.endOfText || (this.char == '|' && this.behind.slice(-1) != '\\'); return this.testClosureEnd() || this.endOfText || (this.char == '|' && this.behind.slice(-1) != '\\');