diff --git a/client/editor.js b/client/editor.js index 8dca1eac..4f953fdf 100644 --- a/client/editor.js +++ b/client/editor.js @@ -43,8 +43,10 @@ const forceRefresh = (from_construct_stage) => { } if (!_.isEqual(output, current)) { glyph.stages[stage.type] = output; - for (let i = types.indexOf(stage.type) + 1; i < types.length; i++) { - glyph.stages[types[i]] = null; + if (!output || !current || stage.clearLaterStages(output, current)) { + for (let i = types.indexOf(stage.type) + 1; i < types.length; i++) { + glyph.stages[types[i]] = null; + } } Session.set('editor.glyph', glyph); } diff --git a/client/lib/abstract.js b/client/lib/abstract.js index 93587336..b5ecd272 100644 --- a/client/lib/abstract.js +++ b/client/lib/abstract.js @@ -38,6 +38,12 @@ stages.AbstractStage = class AbstractStage { Session.set('stage.points', undefined); Session.set('stage.status', undefined); } + // Returns true if the difference between the two outputs is significant + // enough that the output from all later stages must be erased. By default, + // we return true to be safe. We should be very careful when returning false. + clearLaterStages(output1, output2) { + return true; + } // Return this stage's value based on current internal state. The default // implementation works for stages that follow the 'original/adjusted' // convention described in the constructor. diff --git a/client/lib/analysis.js b/client/lib/analysis.js index b2a081af..9f03d375 100644 --- a/client/lib/analysis.js +++ b/client/lib/analysis.js @@ -130,6 +130,9 @@ stages.analysis = class AnalysisStage extends stages.AbstractStage { stage = this; updateStatus(); } + clearLaterStages(output1, output2) { + return output1.decomposition !== output2.decomposition; + } getStageOutput() { return { decomposition: decomposition_util.convertTreeToDecomposition(this.tree),