From ff4fd494811d326986cfe0305f35b89e37dd493c Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Sat, 28 Mar 2026 05:15:49 +0900 Subject: no=op validation, and red tool error messages --- src/tools.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/tools.ts') diff --git a/src/tools.ts b/src/tools.ts index a4eb16e..57e21c1 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -338,6 +338,11 @@ async function executeEditFile(app: App, args: Record): Promise const oldText = typeof args.old_text === "string" ? args.old_text : ""; const newText = typeof args.new_text === "string" ? args.new_text : ""; + // Reject no-op edits where old_text and new_text are identical + if (oldText === newText) { + return `Error: old_text and new_text are identical — no change would occur. Provide different text for new_text, or skip this edit.`; + } + const file = app.vault.getAbstractFileByPath(filePath); if (file === null || !(file instanceof TFile)) { return `Error: File not found at path "${filePath}".`; -- cgit v1.2.3