From 4439bd7c682b7a96a15b170f4f5e3c7204e08867 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Mon, 9 Sep 2024 12:26:38 +0800 Subject: feat: Don't add suggestions in cases --- src/editor.mjs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/editor.mjs b/src/editor.mjs index ba54aa9..281182e 100644 --- a/src/editor.mjs +++ b/src/editor.mjs @@ -213,6 +213,16 @@ const getSuggestionsFromAliases = (option) => Object.entries(aliasesForMapOption }) ?? [] // }}} +const handleTypingInCodeBlock = (currentLine, selection) => { + const text = currentLine.textContent + if (text.match(/^\s\+$/) && text.length % 2 != 0) { + // TODO Completion for even number of spaces + } else if (text.match(/^-/)){ + // TODO Completion for YAML doc separator + } else { + addSuggestions(currentLine, selection) + } +} // FUNCTION: Add HTML element for List of suggestions {{{ const addSuggestions = (currentLine, selection) => { const text = currentLine.textContent @@ -362,7 +372,9 @@ tinyEditor.addEventListener('selection', selection => { } // Show suggestions for map code block - if (insideCodeblockForMap(element)) addSuggestions(element, selection) + if (insideCodeblockForMap(element)) { + handleTypingInCodeBlock(element, selection) + } }); // }}} // EVENT: keydown for suggestions {{{ -- cgit v1.2.3-70-g09d2