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 {
|
else {
|
||||||
let matchingOptions = parserResult.optionList
|
let matchingOptions = parserResult.optionList
|
||||||
.filter(it => isReplacable || it.name == '' ? matchers[matchType](it.name) : it.name.toLowerCase() == slashCommand) // Filter by the input
|
.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
|
result = matchingOptions
|
||||||
.filter((it,idx) => matchingOptions.indexOf(it) == idx)
|
.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.selectionStart = parserResult.start - 2 + selectedItem.replacer.length;
|
||||||
textarea.selectionEnd = textarea.selectionStart;
|
textarea.selectionEnd = textarea.selectionStart;
|
||||||
show();
|
show();
|
||||||
|
} else {
|
||||||
|
const selectionStart = textarea.selectionStart;
|
||||||
|
const selectionEnd = textarea.selectionDirection;
|
||||||
|
await pointerup;
|
||||||
|
textarea.focus();
|
||||||
|
textarea.selectionStart = selectionStart;
|
||||||
|
textarea.selectionDirection = selectionEnd;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const showAutoCompleteDebounced = show;
|
const showAutoCompleteDebounced = show;
|
||||||
|
@ -2381,7 +2388,7 @@ export async function setSlashCommandAutoComplete(textarea, isFloating = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// textarea.addEventListener('blur', ()=>hide());
|
textarea.addEventListener('blur', ()=>hide());
|
||||||
if (isFloating) {
|
if (isFloating) {
|
||||||
textarea.addEventListener('scroll', debounce(updateFloatingPosition, 100));
|
textarea.addEventListener('scroll', debounce(updateFloatingPosition, 100));
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,12 +178,14 @@ export class SlashCommandParser {
|
||||||
* @param {*} index Index to check for names (cursor position).
|
* @param {*} index Index to check for names (cursor position).
|
||||||
*/
|
*/
|
||||||
getNameAt(text, index) {
|
getNameAt(text, index) {
|
||||||
|
if (this.text != `{:${text}:}`) {
|
||||||
try {
|
try {
|
||||||
this.parse(text, false);
|
this.parse(text, false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// do nothing
|
// do nothing
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
index += 2;
|
index += 2;
|
||||||
const executor = this.commandIndex
|
const executor = this.commandIndex
|
||||||
.filter(it=>it.start <= index && (it.end >= index || it.end == null))
|
.filter(it=>it.start <= index && (it.end >= index || it.end == null))
|
||||||
|
|
Loading…
Reference in New Issue