From 3e2d20f37c47cd0a9ba53d15db97aa0207d40908 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Mon, 21 Apr 2025 22:57:58 -0400 Subject: [PATCH] Search and replace fixes (#2830) * Allow replacing with an empty string * Visual cleanup --- src/core/tools/searchAndReplaceTool.ts | 2 +- webview-ui/src/components/chat/ChatRow.tsx | 26 ++------------------- webview-ui/src/i18n/locales/de/chat.json | 2 +- webview-ui/src/i18n/locales/en/chat.json | 2 +- webview-ui/src/i18n/locales/ja/chat.json | 2 +- webview-ui/src/i18n/locales/zh-CN/chat.json | 2 +- webview-ui/src/i18n/locales/zh-TW/chat.json | 2 +- 7 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/core/tools/searchAndReplaceTool.ts b/src/core/tools/searchAndReplaceTool.ts index f371901e5f..7a503b5f1e 100644 --- a/src/core/tools/searchAndReplaceTool.ts +++ b/src/core/tools/searchAndReplaceTool.ts @@ -41,7 +41,7 @@ async function validateParams( return false } - if (!replace) { + if (replace === undefined) { cline.consecutiveMistakeCount++ cline.recordToolError("search_and_replace") pushToolResult(await cline.sayAndCreateMissingParamError("search_and_replace", "replace")) diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index 486183c150..8c09b101b1 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -323,36 +323,14 @@ export const ChatRowContent = ({ case "searchAndReplace": return ( <> -
+
{toolIcon("replace")} - + {message.type === "ask" ? t("chat:fileOperations.wantsToSearchReplace") : t("chat:fileOperations.didSearchReplace")}
-
-
- Search: - {tool.search} - {tool.useRegex && (regex)} - {tool.ignoreCase && ( - (case-insensitive) - )} -
-
- Replace: - {tool.replace} -
- {(tool.startLine !== undefined || tool.endLine !== undefined) && ( -
- Lines: - - {tool.startLine ?? 1} - {tool.endLine ?? "end"} - -
- )} -