when to show autocomplete vs info only

This commit is contained in:
LenAnderson
2024-04-05 10:41:16 -04:00
parent 12a5105312
commit 35f2770d6e

View File

@ -2006,7 +2006,7 @@ export function setNewSlashCommandAutoComplete(textarea, isFloating = false) {
}; };
const show = (isInput = false, isForced = false) => { const show = (isInput = false, isForced = false) => {
//TODO check if isInput and isForced are both required //TODO check if isInput and isForced are both required
isForced = isForced || isInput; // isForced = isForced || isInput;
text = textarea.value; text = textarea.value;
// only show with textarea in focus // only show with textarea in focus
if (document.activeElement != textarea) return hide(); if (document.activeElement != textarea) return hide();
@ -2016,7 +2016,7 @@ export function setNewSlashCommandAutoComplete(textarea, isFloating = false) {
executor = parser.getCommandAt(text, textarea.selectionStart); executor = parser.getCommandAt(text, textarea.selectionStart);
let slashCommand = executor?.name?.toLowerCase() ?? ''; let slashCommand = executor?.name?.toLowerCase() ?? '';
isReplacable = isInput && (!executor ? true : textarea.selectionStart == executor.start - 2 + executor.name.length + 1); isReplacable = isInput && (!executor ? true : textarea.selectionStart == executor.start - 2 + executor.name.length + 1);
if (isForced && textarea.selectionStart > executor.start - 2 && textarea.selectionStart <= executor.start - 2 + executor.name.length + 1) { if ((isForced || isInput) && textarea.selectionStart > executor.start - 2 && textarea.selectionStart <= executor.start - 2 + executor.name.length + 1) {
slashCommand = slashCommand.slice(0, textarea.selectionStart - (executor.start - 2) - 1); slashCommand = slashCommand.slice(0, textarea.selectionStart - (executor.start - 2) - 1);
executor.name = slashCommand; executor.name = slashCommand;
executor.end = executor.start + slashCommand.length; executor.end = executor.start + slashCommand.length;