From e3389aebc0bde2ed1503487bee9844f2e198b446 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 10 Jan 2025 22:53:53 -0800 Subject: [PATCH] remove diff blocks in reverse order plus delay to solve bug --- extensions/vscode/src/diff/vertical/handler.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index 4d8a99020..ced48e03d 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -10,8 +10,8 @@ import { redDecorationType, } from "./decorations"; -import type { VerticalDiffCodeLens } from "./manager"; import type { ApplyState, DiffLine } from "core"; +import type { VerticalDiffCodeLens } from "./manager"; export interface VerticalDiffHandlerOptions { input?: string; @@ -486,9 +486,12 @@ export class VerticalDiffHandler implements vscode.Disposable { * we have received all of the diff lines. */ async reapplyWithMeyersDiff(diffLines: DiffLine[]) { + // Diff is messed up without this delay. + await new Promise((resolve) => setTimeout(resolve, 100)); + // First, we reset the original diff by rejecting all pending diff blocks - for (const block of this.editorToVerticalDiffCodeLens.get(this.fileUri) ?? - []) { + const blocks = this.editorToVerticalDiffCodeLens.get(this.fileUri) ?? []; + for (const block of blocks.reverse()) { await this.acceptRejectBlock( false, block.start,