diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-09-09 12:26:38 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-09-09 12:28:27 +0800 |
commit | 4439bd7c682b7a96a15b170f4f5e3c7204e08867 (patch) | |
tree | af7fe64009e479f8d8ab51452cad1c6be3542de5 /src | |
parent | 65c53c7652724fee1ef1df7fd85d981438d7ccca (diff) |
feat: Don't add suggestions in cases
Diffstat (limited to 'src')
-rw-r--r-- | src/editor.mjs | 14 |
1 files changed, 13 insertions, 1 deletions
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 | |||
213 | }) | 213 | }) |
214 | ?? [] | 214 | ?? [] |
215 | // }}} | 215 | // }}} |
216 | const handleTypingInCodeBlock = (currentLine, selection) => { | ||
217 | const text = currentLine.textContent | ||
218 | if (text.match(/^\s\+$/) && text.length % 2 != 0) { | ||
219 | // TODO Completion for even number of spaces | ||
220 | } else if (text.match(/^-/)){ | ||
221 | // TODO Completion for YAML doc separator | ||
222 | } else { | ||
223 | addSuggestions(currentLine, selection) | ||
224 | } | ||
225 | } | ||
216 | // FUNCTION: Add HTML element for List of suggestions {{{ | 226 | // FUNCTION: Add HTML element for List of suggestions {{{ |
217 | const addSuggestions = (currentLine, selection) => { | 227 | const addSuggestions = (currentLine, selection) => { |
218 | const text = currentLine.textContent | 228 | const text = currentLine.textContent |
@@ -362,7 +372,9 @@ tinyEditor.addEventListener('selection', selection => { | |||
362 | } | 372 | } |
363 | 373 | ||
364 | // Show suggestions for map code block | 374 | // Show suggestions for map code block |
365 | if (insideCodeblockForMap(element)) addSuggestions(element, selection) | 375 | if (insideCodeblockForMap(element)) { |
376 | handleTypingInCodeBlock(element, selection) | ||
377 | } | ||
366 | }); | 378 | }); |
367 | // }}} | 379 | // }}} |
368 | // EVENT: keydown for suggestions {{{ | 380 | // EVENT: keydown for suggestions {{{ |