fix: text_editor add trailing newline to patch content to avoid line merging
linuztx committed
Feb 27, 2026 at 22:53 UTC
bfe5ed17a597f7b8c9867d4d61dd7eb2e4fed4d4
1 file changed
+5
plugins/text_editor/helpers/file_ops.py
+5
@@ -229,6 +229,11 @@ def apply_patch(path: str, edits: list[dict]) -> int:
229
Inserts have 'insert': True.
230
Returns total line count after patching.
231
"""
232
+ # Ensure content always ends with newline to prevent line merging
233
+ for e in edits:
234
+ if e["content"] and not e["content"].endswith("\n"):
235
+ e["content"] += "\n"
236
+
237
dir_name = os.path.dirname(path) or "."
238
fd, tmp_path = tempfile.mkstemp(dir=dir_name, suffix=".tmp")
239
try: