From 4d9cd31e36a379cd47d77d1abe074f70cb2ff346 Mon Sep 17 00:00:00 2001 From: MischaPanch Date: Fri, 15 Aug 2025 13:43:57 +0200 Subject: [PATCH] Docstring: reminder to escape appropriately in replace_regex (\\n for inserting \n) [ci skip] --- src/serena/tools/file_tools.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/serena/tools/file_tools.py b/src/serena/tools/file_tools.py index dfba909e..008ba2b1 100644 --- a/src/serena/tools/file_tools.py +++ b/src/serena/tools/file_tools.py @@ -179,7 +179,7 @@ class ReplaceRegexTool(Tool, ToolMarkerCanEdit): the form "beginning.*?end-of-text-to-be-replaced". Always try to use wildcards to avoid specifying the exact content of the code to be replaced, especially if it spans several lines. - + IMPORTANT: REMEMBER TO USE WILDCARDS WHEN APPROPRIATE! I WILL BE VERY UNHAPPY IF YOU WRITE LONG REGEXES WITHOUT USING WILDCARDS INSTEAD! :param relative_path: the relative path to the file @@ -187,6 +187,7 @@ class ReplaceRegexTool(Tool, ToolMarkerCanEdit): Dot matches all characters, multi-line matching is enabled. :param repl: the string to replace the matched content with, which may contain backreferences like \1, \2, etc. + Make sure to escape special characters appropriately, e.g., use `\\n` for a literal `\n`. :param allow_multiple_occurrences: if True, the regex may match multiple occurrences in the file and all of them will be replaced. If this is set to False and the regex matches multiple occurrences, an error will be returned