From de5aacddd2a4710c518ca0fcf707784816d20b12 Mon Sep 17 00:00:00 2001 From: "CK iRonin.IT" Date: Fri, 3 Apr 2026 14:52:15 -0400 Subject: [PATCH] fix: normalise \r\n and \r line endings in pasted text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows (CRLF) and old Mac (CR) line endings are normalised to LF before the 5-line collapse threshold is checked in handle_paste. Without this, markdown copied from Windows sources contains \r\n but the line counter (pasted_text.count('\n')) still works — however buf.insert_text() leaves bare \r characters in the buffer which some terminals render by moving the cursor to the start of the line, making multi-line pastes appear as a single overwritten line. --- cli.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cli.py b/cli.py index 42a49440cd7..985b9ba1af8 100644 --- a/cli.py +++ b/cli.py @@ -7010,6 +7010,9 @@ class HermesCLI: buffer. """ pasted_text = event.data or "" + # Normalise line endings — Windows \r\n and old Mac \r both become \n + # so the 5-line collapse threshold and display are consistent. + pasted_text = pasted_text.replace('\r\n', '\n').replace('\r', '\n') if self._try_attach_clipboard_image(): event.app.invalidate() if pasted_text: