From 7e427e5bb98a7a5bfc36ff402aa3c31602e2cdc1 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Thu, 20 Oct 2022 16:44:11 +0200 Subject: [PATCH] Fixing history rendering of expressions --- .../eu/ad5001/LogarithmPlotter/js/history/editproperty.js | 8 ++++++-- .../qml/eu/ad5001/LogarithmPlotter/js/math/expression.js | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/history/editproperty.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/history/editproperty.js index b2862a2..17cc28f 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/history/editproperty.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/history/editproperty.js @@ -42,7 +42,7 @@ class EditedProperty extends C.Action { this.newValue = newValue this.propertyType = Objects.types[targetType].properties()[targetProperty] if(valueIsExpressionNeedingImport) { - if(this.propertyType == "Expression") { + if(typeof this.propertyType == 'object' && this.propertyType.type == "Expression") { this.previousValue = new MathLib.Expression(this.previousValue); this.newValue = new MathLib.Expression(this.newValue); } else if(this.propertyType == "Domain") { @@ -98,6 +98,10 @@ class EditedProperty extends C.Action { this.prevString = JSON.stringify(this.previousValue) this.nextString = JSON.stringify(this.newValue) break; + case "Expression": + this.prevString = this.previousValue == null ? "null" : this.previousValue.toString() + this.nextString = this.newValue == null ? "null" : this.newValue.toString() + break; } } else { this.prevString = this.previousValue == null ? "null" : this.previousValue.toString() @@ -106,7 +110,7 @@ class EditedProperty extends C.Action { // HTML this.prevHTML = ' '+this.prevString+' ' this.nextHTML = ' '+this.nextString+' ' - if(Latex.enabled && this.propertyType == "Expression") { + if(Latex.enabled && typeof this.propertyType == 'object' && this.propertyType.type == "Expression") { this.prevHTML= this.renderLatexAsHtml(this.previousValue.latexMarkup) this.nextHTML= this.renderLatexAsHtml(this.newValue.latexMarkup) } diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/math/expression.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/math/expression.js index a9b008a..9993152 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/math/expression.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/math/expression.js @@ -63,7 +63,6 @@ class Expression { return this.cachedValue } C.currentVars = Object.assign({'x': x}, C.currentObjectsByName) - //console.log("Executing", this.expr, "with", JSON.stringify(C.currentVars)) return this.calc.evaluate(C.currentVars) }