From f06113120db114ce823d4a4b7385b54a69c1c55e Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Mon, 23 Feb 2026 05:32:10 -0500 Subject: [PATCH] strip trailing newlines with "\e " Trailing newlines were stripped in other variations of "\e", but not when reading from a file. Stripping helps place the cursor in the expected place when returning to the prompt. --- changelog.md | 1 + mycli/packages/special/iocommands.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 130f44b1..360c27e2 100644 --- a/changelog.md +++ b/changelog.md @@ -11,6 +11,7 @@ Bug Fixes * Let interactive changes to the prompt format respect dynamically-computed values. * Better handle arguments to `system cd`. * Fix missing keepalives in `\e` prompt loop. +* Always strip trailing newlines with `\e`. 1.56.0 (2026/02/23) diff --git a/mycli/packages/special/iocommands.py b/mycli/packages/special/iocommands.py index 96904f86..47ab3a06 100644 --- a/mycli/packages/special/iocommands.py +++ b/mycli/packages/special/iocommands.py @@ -194,7 +194,7 @@ def open_external_editor(filename: str | None = None, sql: str | None = None) -> query = f.read() except IOError: message = f'Error reading file: {filename}' - return (query, message) + return (query.rstrip('\n'), message) # Populate the editor buffer with the partial sql (if available) and a # placeholder comment.