From babe1f30a2310e81ec64acb3355c0e119a16eaee Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sun, 28 Apr 2024 18:37:03 -0400 Subject: [PATCH] Prevent autosuggest inside curly span/div properties --- shared/naturalcrit/codeEditor/autocomplete-emoji.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shared/naturalcrit/codeEditor/autocomplete-emoji.js b/shared/naturalcrit/codeEditor/autocomplete-emoji.js index 87950322f..de550ff66 100644 --- a/shared/naturalcrit/codeEditor/autocomplete-emoji.js +++ b/shared/naturalcrit/codeEditor/autocomplete-emoji.js @@ -60,7 +60,16 @@ const showEmojiAutocomplete = function(CodeMirror, editor) { // Get the text from the start of the line to the cursor const textToCursor = line.slice(0, cursor.ch); - + + // Do not autosuggest emojis in curly span/div properties + if(line.includes('{{')) { + const curlyToCursor = textToCursor.slice(textToCursor.indexOf(`{{`)); + const curlySpanRegex = /{{(?=((?:[:=](?:"[\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"':={}\s]*)*))\1$/g; + + if (regex.test(curlyToCursor)) + return; + } + // Check if the text ends with ':xyz' if (/:[^\s:]+$/.test(textToCursor)) { CodeMirror.commands.autocomplete(editor);