From 090bddbcea3e48a2acd3b06a22a6fbcb3de1ddaf Mon Sep 17 00:00:00 2001 From: canvrno <46584286+canvrno@users.noreply.github.com> Date: Wed, 25 Jun 2025 14:43:26 -0700 Subject: [PATCH] Fix: Accept trailing ">" on search and replace blocks (#4427) * Modified regex to account for trailing > characters in search and replace blocks * added check back to other regex's * Re-ordered regex consts for readability --- .changeset/nine-dolphins-judge.md | 5 +++++ src/core/assistant-message/diff.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .changeset/nine-dolphins-judge.md diff --git a/.changeset/nine-dolphins-judge.md b/.changeset/nine-dolphins-judge.md new file mode 100644 index 0000000000..bfcf8b4abe --- /dev/null +++ b/.changeset/nine-dolphins-judge.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Modified diff regex to account for trailing > in search & replace blocks diff --git a/src/core/assistant-message/diff.ts b/src/core/assistant-message/diff.ts index e03d77243a..f5696fc652 100644 --- a/src/core/assistant-message/diff.ts +++ b/src/core/assistant-message/diff.ts @@ -8,11 +8,13 @@ const LEGACY_SEARCH_BLOCK_CHAR = "<" const LEGACY_REPLACE_BLOCK_CHAR = ">" // Replace the exact string constants with flexible regex patterns -const SEARCH_BLOCK_START_REGEX = /^[-]{3,} SEARCH$/ +const SEARCH_BLOCK_START_REGEX = /^[-]{3,} SEARCH>?$/ +const LEGACY_SEARCH_BLOCK_START_REGEX = /^[<]{3,} SEARCH>?$/ + const SEARCH_BLOCK_END_REGEX = /^[=]{3,}$/ -const REPLACE_BLOCK_END_REGEX = /^[+]{3,} REPLACE$/ -const LEGACY_SEARCH_BLOCK_START_REGEX = /^[<]{3,} SEARCH$/ -const LEGACY_REPLACE_BLOCK_END_REGEX = /^[>]{3,} REPLACE$/ + +const REPLACE_BLOCK_END_REGEX = /^[+]{3,} REPLACE>?$/ +const LEGACY_REPLACE_BLOCK_END_REGEX = /^[>]{3,} REPLACE>?$/ // Helper functions to check if a line matches the flexible patterns function isSearchBlockStart(line: string): boolean {