From 59d0fe00c3241b74610af59e5f1b82721191ed67 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 21 Nov 2024 10:09:36 -0800 Subject: [PATCH] refactor: Improve multi-line input handling with strict closing tag validation --- aider/io.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/aider/io.py b/aider/io.py index 0967b0da7..625ee42dd 100644 --- a/aider/io.py +++ b/aider/io.py @@ -452,17 +452,18 @@ class InputOutput: multiline_tag = None inp += line[1:] + "\n" continue - elif line and line[-1] == "}" and multiline_input: + elif multiline_input and line.strip(): if multiline_tag: - # Check if the line ends with tag} - if line.endswith(f"{multiline_tag}}}"): - inp += line[: -len(multiline_tag) - 1] + "\n" + # Check if line is exactly "tag}" + if line.strip() == f"{multiline_tag}}}": break else: inp += line + "\n" - else: - inp += line[:-1] + "\n" + # Check if line is exactly "}" + elif line.strip() == "}": break + else: + inp += line + "\n" elif multiline_input: inp += line + "\n" else: