Skip to content

Commit

Permalink
when replacing file content generalize double escape backslashes
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonOstrez committed Oct 21, 2023
1 parent 6249093 commit 0665b28
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pilot/helpers/AgentConvo.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ def replace_files(self):
def replace_file_content(self, message, file_path, new_content):
escaped_file_path = re.escape(file_path)

# Escape any \U in the file path
escaped_file_path = escaped_file_path.replace("\\U", "\\\\U")
# Double escape backslashes in new_content
new_content = new_content.replace("\\", "\\\\")

pattern = rf'\*\*{{ {escaped_file_path} }}\*\*\n```\n(.*?)\n```'

Expand Down

0 comments on commit 0665b28

Please sign in to comment.