From 4ca5fcfeb202c77729b2f3f294b538cb3550a6bd Mon Sep 17 00:00:00 2001 From: frikky Date: Thu, 27 Oct 2022 17:59:19 +0200 Subject: [PATCH] Fixed issue with variable parsing that is not JSON --- frontend/src/components/ShuffleCodeEditor.jsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/ShuffleCodeEditor.jsx b/frontend/src/components/ShuffleCodeEditor.jsx index 2592fb3c..5ba568f2 100644 --- a/frontend/src/components/ShuffleCodeEditor.jsx +++ b/frontend/src/components/ShuffleCodeEditor.jsx @@ -305,7 +305,6 @@ const CodeEditor = (props) => { variable_occurence = new_occurences.valueOf() console.log("Match2: ", variable_occurence) - // console.log(variable_occurence) // console.log() @@ -410,7 +409,7 @@ const CodeEditor = (props) => { // return //} - //console.log("FOUND: ", found) + console.log("FOUND: ", found) // Whelp this is inefficient af. Single loop pls // When the found array is empty. @@ -426,8 +425,15 @@ const CodeEditor = (props) => { for (var j = 0; j < actionlist.length; j++) { if(fixedVariable.slice(1,).toLowerCase() === actionlist[j].autocomplete.toLowerCase()){ valuefound = true + + console.log("Valuefound: ", fixedVariable, actionlist[j].example) + try { - input = input.replace(fixedVariable, JSON.stringify(actionlist[j].example)); + if (actionlist[j].example.trim().startsWith("{") || actionlist[j].example.trim().startsWith("[")) { + input = input.replace(fixedVariable, JSON.stringify(actionlist[j].example)); + } else { + input = input.replace(fixedVariable, actionlist[j].example) + } } catch (e) { input = input.replace(fixedVariable, actionlist[j].example) }