Compare commits
4 Commits
acdfd10752
...
38e468dc4f
Author | SHA1 | Date |
---|---|---|
LenAnderson | 38e468dc4f | |
LenAnderson | ed01e94c9f | |
LenAnderson | 04fca9f370 | |
LenAnderson | 10e786dfd3 |
|
@ -2067,7 +2067,7 @@ export async function setSlashCommandAutoComplete(textarea, isFloating = false)
|
|||
else {
|
||||
let matchingOptions = parserResult.optionList
|
||||
.filter(it => isReplacable || it.name == '' ? matchers[matchType](it.name) : it.name.toLowerCase() == slashCommand) // Filter by the input
|
||||
.filter((it,idx,list) => list.indexOf(it) == idx)
|
||||
.filter((it,idx,list) => list.findIndex(opt=>opt.value == it.value) == idx)
|
||||
;
|
||||
result = matchingOptions
|
||||
.filter((it,idx) => matchingOptions.indexOf(it) == idx)
|
||||
|
@ -2266,6 +2266,13 @@ export async function setSlashCommandAutoComplete(textarea, isFloating = false)
|
|||
textarea.selectionStart = parserResult.start - 2 + selectedItem.replacer.length;
|
||||
textarea.selectionEnd = textarea.selectionStart;
|
||||
show();
|
||||
} else {
|
||||
const selectionStart = textarea.selectionStart;
|
||||
const selectionEnd = textarea.selectionDirection;
|
||||
await pointerup;
|
||||
textarea.focus();
|
||||
textarea.selectionStart = selectionStart;
|
||||
textarea.selectionDirection = selectionEnd;
|
||||
}
|
||||
};
|
||||
const showAutoCompleteDebounced = show;
|
||||
|
@ -2381,7 +2388,7 @@ export async function setSlashCommandAutoComplete(textarea, isFloating = false)
|
|||
}
|
||||
}
|
||||
});
|
||||
// textarea.addEventListener('blur', ()=>hide());
|
||||
textarea.addEventListener('blur', ()=>hide());
|
||||
if (isFloating) {
|
||||
textarea.addEventListener('scroll', debounce(updateFloatingPosition, 100));
|
||||
}
|
||||
|
|
|
@ -178,11 +178,13 @@ export class SlashCommandParser {
|
|||
* @param {*} index Index to check for names (cursor position).
|
||||
*/
|
||||
getNameAt(text, index) {
|
||||
try {
|
||||
this.parse(text, false);
|
||||
} catch (e) {
|
||||
// do nothing
|
||||
console.warn(e);
|
||||
if (this.text != `{:${text}:}`) {
|
||||
try {
|
||||
this.parse(text, false);
|
||||
} catch (e) {
|
||||
// do nothing
|
||||
console.warn(e);
|
||||
}
|
||||
}
|
||||
index += 2;
|
||||
const executor = this.commandIndex
|
||||
|
|
Loading…
Reference in New Issue