diff --git a/src/core/Cline.ts b/src/core/Cline.ts index c1c5bf186a..7a118d10a8 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -1602,6 +1602,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,