From 3d2e6aea7bf32061a5c8e2cb5a34b7cfb559b1fd Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 23 May 2017 15:54:09 +0100 Subject: [PATCH] Remember test expression data on a per-node basis --- editor/js/ui/editor.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index f9883e418..622861ab5 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -1657,7 +1657,14 @@ RED.editor = (function() { } + var expressionTestCache = {}; + function editExpression(options) { + var expressionTestCacheId = "_"; + if (editStack.length > 0) { + expressionTestCacheId = editStack[editStack.length-1].id; + } + var value = options.value; var onComplete = options.complete; var type = "_expression" @@ -1838,7 +1845,7 @@ RED.editor = (function() { }); testDataEditor = RED.editor.createEditor({ id: 'node-input-expression-test-data', - value: '{\n "payload": "hello world"\n}', + value: expressionTestCache[expressionTestCacheId] || '{\n "payload": "hello world"\n}', mode:"ace/mode/json", lineNumbers: false }); @@ -1900,6 +1907,7 @@ RED.editor = (function() { testDataEditor.getSession().on('change', function() { clearTimeout(changeTimer); changeTimer = setTimeout(testExpression,200); + expressionTestCache[expressionTestCacheId] = testDataEditor.getValue(); }); expressionEditor.getSession().on('change', function() { clearTimeout(changeTimer);