diff --git a/.changes/unreleased/Fixed-20250129-095107.yaml b/.changes/unreleased/Fixed-20250129-095107.yaml new file mode 100644 index 0000000000..9404c5fe22 --- /dev/null +++ b/.changes/unreleased/Fixed-20250129-095107.yaml @@ -0,0 +1,3 @@ +kind: Fixed +body: Fix for the "Diff Edit Failed" / "replace_in_file" defects - #1010 #1511 #953 +time: 2025-01-29T09:51:07.5008655-05:00 diff --git a/src/core/Cline.ts b/src/core/Cline.ts index c234b721b8..c9c3e3c066 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -1595,6 +1595,13 @@ export class Cline { diff = fixModelHtmlEscaping(diff) diff = removeInvalidChars(diff) } + + // open the editor if not done already. This is to fix diff error when model provides correct search-replace text but Cline throws error + // because file is not open. + if (!this.diffViewProvider.isEditing) { + await this.diffViewProvider.open(relPath) + } + try { newContent = await constructNewFileContent( diff,