Browse Source

Search and replace fixes (#2830)

* Allow replacing with an empty string

* Visual cleanup
Matt Rubens 8 months ago
parent
commit
3e2d20f37c

+ 1 - 1
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"))

+ 2 - 24
webview-ui/src/components/chat/ChatRow.tsx

@@ -323,36 +323,14 @@ export const ChatRowContent = ({
 			case "searchAndReplace":
 				return (
 					<>
-						<div className="flex items-center gap-2.5 mb-2.5">
+						<div style={headerStyle}>
 							{toolIcon("replace")}
-							<span className="font-bold">
+							<span style={{ fontWeight: "bold" }}>
 								{message.type === "ask"
 									? t("chat:fileOperations.wantsToSearchReplace")
 									: t("chat:fileOperations.didSearchReplace")}
 							</span>
 						</div>
-						<div className="mb-2.5">
-							<div className="flex items-center gap-2.5 mb-1.5">
-								<span className="text-vscode-descriptionForeground">Search:</span>
-								<code>{tool.search}</code>
-								{tool.useRegex && <span className="text-vscode-descriptionForeground">(regex)</span>}
-								{tool.ignoreCase && (
-									<span className="text-vscode-descriptionForeground">(case-insensitive)</span>
-								)}
-							</div>
-							<div className="flex items-center gap-2.5 mb-1.5">
-								<span className="text-vscode-descriptionForeground">Replace:</span>
-								<code>{tool.replace}</code>
-							</div>
-							{(tool.startLine !== undefined || tool.endLine !== undefined) && (
-								<div className="flex items-center gap-2.5">
-									<span className="text-vscode-descriptionForeground">Lines:</span>
-									<code>
-										{tool.startLine ?? 1} - {tool.endLine ?? "end"}
-									</code>
-								</div>
-							)}
-						</div>
 						<CodeAccordian
 							progressStatus={message.progressStatus}
 							isLoading={message.partial}

+ 1 - 1
webview-ui/src/i18n/locales/de/chat.json

@@ -121,7 +121,7 @@
 		"wantsToEdit": "Roo möchte diese Datei bearbeiten:",
 		"wantsToEditOutsideWorkspace": "Roo möchte diese Datei außerhalb des Arbeitsbereichs bearbeiten:",
 		"wantsToCreate": "Roo möchte eine neue Datei erstellen:",
-		"wantsToSearchReplace": "Roo möchte Suchen und Ersetzen in dieser Datei durchführen:",
+		"wantsToSearchReplace": "Roo möchte in dieser Datei suchen und ersetzen:",
 		"didSearchReplace": "Roo hat Suchen und Ersetzen in dieser Datei durchgeführt:",
 		"wantsToInsert": "Roo möchte Inhalte in diese Datei einfügen:",
 		"wantsToInsertWithLineNumber": "Roo möchte Inhalte in diese Datei in Zeile {{lineNumber}} einfügen:",

+ 1 - 1
webview-ui/src/i18n/locales/en/chat.json

@@ -116,7 +116,7 @@
 		"wantsToEdit": "Roo wants to edit this file:",
 		"wantsToEditOutsideWorkspace": "Roo wants to edit this file outside of the workspace:",
 		"wantsToCreate": "Roo wants to create a new file:",
-		"wantsToSearchReplace": "Roo wants to perform search and replace on this file:",
+		"wantsToSearchReplace": "Roo wants to search and replace in this file:",
 		"didSearchReplace": "Roo performed search and replace on this file:",
 		"wantsToInsert": "Roo wants to insert content into this file:",
 		"wantsToInsertWithLineNumber": "Roo wants to insert content into this file at line {{lineNumber}}:",

+ 1 - 1
webview-ui/src/i18n/locales/ja/chat.json

@@ -121,7 +121,7 @@
 		"wantsToEdit": "Rooはこのファイルを編集したい:",
 		"wantsToEditOutsideWorkspace": "Rooはワークスペース外のこのファイルを編集したい:",
 		"wantsToCreate": "Rooは新しいファイルを作成したい:",
-		"wantsToSearchReplace": "Rooはこのファイルで検索と置換を実行したい:",
+		"wantsToSearchReplace": "Rooはこのファイルで検索と置換を行う:",
 		"didSearchReplace": "Rooはこのファイルで検索と置換を実行しました:",
 		"wantsToInsert": "Rooはこのファイルにコンテンツを挿入したい:",
 		"wantsToInsertWithLineNumber": "Rooはこのファイルの{{lineNumber}}行目にコンテンツを挿入したい:",

+ 1 - 1
webview-ui/src/i18n/locales/zh-CN/chat.json

@@ -121,7 +121,7 @@
 		"wantsToEdit": "需要编辑文件:",
 		"wantsToEditOutsideWorkspace": "需要编辑外部文件:",
 		"wantsToCreate": "需要新建文件:",
-		"wantsToSearchReplace": "需要执行搜索和替换:",
+		"wantsToSearchReplace": "需要在此文件中搜索和替换:",
 		"didSearchReplace": "已完成搜索和替换:",
 		"wantsToInsert": "需要在此文件中插入内容:",
 		"wantsToInsertWithLineNumber": "需要在第 {{lineNumber}} 行插入内容:",

+ 1 - 1
webview-ui/src/i18n/locales/zh-TW/chat.json

@@ -121,7 +121,7 @@
 		"wantsToEdit": "Roo 想要編輯此檔案:",
 		"wantsToEditOutsideWorkspace": "Roo 想要編輯此工作區外的檔案:",
 		"wantsToCreate": "Roo 想要建立新檔案:",
-		"wantsToSearchReplace": "Roo 想要在此檔案執行搜尋和取代:",
+		"wantsToSearchReplace": "Roo 想要在此檔案搜尋和取代:",
 		"didSearchReplace": "Roo 已在此檔案執行搜尋和取代:",
 		"wantsToInsert": "Roo 想要在此檔案中插入內容:",
 		"wantsToInsertWithLineNumber": "Roo 想要在此檔案第 {{lineNumber}} 行插入內容:",