From 10b5ac52ddc92cbbb2f8eb6edebeddc0042470ba Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 18 Sep 2024 07:51:13 -0700 Subject: [PATCH] solve another test --- core/edit/lazy/deterministic.ts | 12 +----------- core/edit/lazy/test-examples/top-level-same.js.diff | 10 +++++----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/core/edit/lazy/deterministic.ts b/core/edit/lazy/deterministic.ts index 8b6e2a7f7..232914d0c 100644 --- a/core/edit/lazy/deterministic.ts +++ b/core/edit/lazy/deterministic.ts @@ -137,16 +137,6 @@ function nodesAreExact(a: Parser.SyntaxNode, b: Parser.SyntaxNode): boolean { return a.text === b.text; } -function diffLinesForNode( - node: Parser.SyntaxNode, - type: DiffLine["type"], -): DiffLine[] { - return node.text.split("\n").map((line) => ({ - line, - type, - })); -} - /** * Should be like Myers diff, but lazy blocks consume all nodes until the next match * @param newNode @@ -229,7 +219,7 @@ function diffNodes( if (isLazy) { acc.push({ lazyBlockNode: currentLazyBlockNode!, - replacementNodes: [...currentLazyBlockReplacementNodes], + replacementNodes: [...currentLazyBlockReplacementNodes, ...leftChildren], }); } diff --git a/core/edit/lazy/test-examples/top-level-same.js.diff b/core/edit/lazy/test-examples/top-level-same.js.diff index f37e4d9bf..97b65a51c 100644 --- a/core/edit/lazy/test-examples/top-level-same.js.diff +++ b/core/edit/lazy/test-examples/top-level-same.js.diff @@ -47,11 +47,11 @@ class Calculator { class Subtract extends Calculator { sub(num1, num2) { this.result = num1 - num2; -+ -+ if (this.result < 0) { -+ throw new Error("Result cannot be negative"); -+ } -+ ++ ++ if (this.result < 0) { ++ throw new Error("Result cannot be negative"); ++ } ++ return this.result; } }