From 740d6588900f497243c83013da211da79676a9a4 Mon Sep 17 00:00:00 2001 From: Scott Vorthmann Date: Sun, 5 Jan 2025 09:08:48 -0800 Subject: [PATCH] Fixed the defect interpreting nested branches --- online/src/worker/legacy/edit.js | 2 +- online/src/worker/legacy/interpreter.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/online/src/worker/legacy/edit.js b/online/src/worker/legacy/edit.js index 39cf3aa7e..9b553ecc7 100644 --- a/online/src/worker/legacy/edit.js +++ b/online/src/worker/legacy/edit.js @@ -41,7 +41,7 @@ export class ParsedEdit perform( context ) { - console.log( 'perform', this.nativeElement.id, this.nativeElement.tagName ); + // console.log( 'perform', this.nativeElement.id, this.nativeElement.tagName ); this.legacyEdit = this.interpret.call( this, this.nativeElement, context ); } diff --git a/online/src/worker/legacy/interpreter.js b/online/src/worker/legacy/interpreter.js index c589b0940..aedc134bd 100644 --- a/online/src/worker/legacy/interpreter.js +++ b/online/src/worker/legacy/interpreter.js @@ -115,15 +115,16 @@ export class Interpreter let top; do { top = this.stack .pop(); + if ( !! top ) { + this.cursor .endBranch( top.branch ); + this.cursor = top.cursor; // overwrite and discard the prior value + this.cursor .setNextEdit( top.branch .nextSibling() ); + } } while ( top && ! top.branch .nextSibling() ) if ( top ) { - this.cursor = top.cursor; // overwrite and discard the prior value - this.cursor .endBranch( top.branch ); - this.cursor .setNextEdit( top.branch .nextSibling() ); - return breakpointHit? Step.DONE : Step.OUT; + return breakpointHit? Step.DONE : Step.OUT; // at the end of a branch } else { - // at the end of the editHistory - return Step.DONE; + return Step.DONE; // at the end of the editHistory } } } @@ -222,6 +223,7 @@ export class EditCursor for (const edit of reversed) { const trueEdit = edit .legacyEdit; if ( trueEdit ) { + // console.log( 'undo', edit.nativeElement.id, edit.nativeElement.tagName ); trueEdit .undo(); } else console.log( 'No true edit?' );