Skip to content

Agent Zero AI framework

fix: text_editor add trailing newline to patch content to avoid line merging

linuztxbfe5ed17a597
diff --git a/plugins/text_editor/helpers/file_ops.py b/plugins/text_editor/helpers/file_ops.py
index 866f57da0..a5b5b8b95 100644
--- a/plugins/text_editor/helpers/file_ops.py
+++ b/plugins/text_editor/helpers/file_ops.py
@@ -229,6 +229,11 @@ def apply_patch(path: str, edits: list[dict]) -> int:
Inserts have 'insert': True.
Returns total line count after patching.
"""
+ # Ensure content always ends with newline to prevent line merging
+ for e in edits:
+ if e["content"] and not e["content"].endswith("\n"):
+ e["content"] += "\n"
+
dir_name = os.path.dirname(path) or "."
fd, tmp_path = tempfile.mkstemp(dir=dir_name, suffix=".tmp")
try: