EL behavior at end of line #4440

Open
opened 2026-01-30 23:47:49 +00:00 by claunia · 0 comments
Owner

Originally created by @egmontkob on GitHub (Oct 13, 2019).

Environment

Windows build number: 10.0.18362.0
Windows Terminal version (if applicable): 0.5.2762.0

Steps to reproduce

Issue an EL (clear to end of line, \e[K) when the cursor is at the rightmost position, in "pending wrap" a.k.a. "delayed eol wrap" state. Print further characters. E.g.:

printf "%$(tput cols)s\e[K%s\n" 0123456789 abcdef

Expected behavior

xterm's behavior, and as far as I know the "official" one is that EL clears the "delayed eol wrap" state along with erasing the last column (9), resulting in (denoting the right margin by a "left one eighth block" ):

          012345678a▏
bcdef               ▏

Some terminals, including VTE, iTerm2, Kitty, Konsole, PuTTY 0.73 intentionally deviate: make EL not clear the "delayed eol wrap" flag and not erase the last character either:

          0123456789▏
abcdef              ▏

Rationale:

There are several utilities that want to just simply print some text with colors or other attributes, without caring about the terminal width or doing anything more complex terminal driving. If these attributes include a background color too, the behavior is messy across a linewrap, due to the terribly designed bce (background color earse) feature. (Now, VTE, and perhaps some other emulators too, intentionally implement bce differently, as another means of mitigating the problem I'm describing here, but let's leave that to another day.)

As a workaround for the background color problem, several utilities decide to also emit an EL after restoring the background color, to earse the faulty color there. And they often don't realize that this introduces an even more serious issue: at linewrap, a character might get dropped from the output. An example is grep with its default settings. PuTTY 0.73's changelog refers to gcc.

Notes We (VTE) haven't received any bugreport about it, nor did I saw one in Kitty's, Konsole's or iTerm2's bugtracker. Also there's no vttest test case for this.

I do recommend that you follow our behavior here. :)

Actual behavior

The last digit 9 is wiped out by EL for no apparent reason since the "delayed eol wrap" state isn't cleared, the first letter a is printed in the next line anyway:

          012345678 ▏
abcdef              ▏

Or, at 38 columns:

echo 'The quick brown fox jumps over the lazy dog.' | GREP_COLORS='ms=1;91' grep z

The quick brown fox jumps over the la ▏
y dog.                                ▏
Originally created by @egmontkob on GitHub (Oct 13, 2019). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: 10.0.18362.0 Windows Terminal version (if applicable): 0.5.2762.0 ``` # Steps to reproduce Issue an EL (clear to end of line, `\e[K`) when the cursor is at the rightmost position, in "pending wrap" a.k.a. "delayed eol wrap" state. Print further characters. E.g.: printf "%$(tput cols)s\e[K%s\n" 0123456789 abcdef # Expected behavior xterm's behavior, and as far as I know the "official" one is that EL clears the "delayed eol wrap" state along with erasing the last column (`9`), resulting in (denoting the right margin by a "left one eighth block" `▏`): 012345678a▏ bcdef ▏ Some terminals, including [VTE](https://bugzilla.gnome.org/show_bug.cgi?id=740789), iTerm2, Kitty, Konsole, PuTTY 0.73 intentionally deviate: make EL not clear the "delayed eol wrap" flag and not erase the last character either: 0123456789▏ abcdef ▏ Rationale: There are several utilities that want to just simply print some text with colors or other attributes, without caring about the terminal width or doing anything more complex terminal driving. If these attributes include a background color too, the behavior is messy across a linewrap, due to the [terribly designed bce (background color earse)](https://bugzilla.gnome.org/show_bug.cgi?id=754596) feature. (Now, VTE, and perhaps some other emulators too, intentionally implement bce differently, as another means of mitigating the problem I'm describing here, but let's leave that to another day.) As a workaround for the background color problem, several utilities decide to also emit an EL after restoring the background color, to earse the faulty color there. And they often don't realize that this introduces an even more serious issue: at linewrap, a character might get dropped from the output. An example is [grep](http://savannah.gnu.org/bugs/?36831) with its default settings. PuTTY 0.73's changelog refers to gcc. Notes We (VTE) haven't received any bugreport about it, nor did I saw one in Kitty's, Konsole's or iTerm2's bugtracker. Also there's no vttest test case for this. I do recommend that you follow our behavior here. :) # Actual behavior The last digit `9` is wiped out by EL for no apparent reason since the "delayed eol wrap" state isn't cleared, the first letter `a` is printed in the next line anyway: 012345678 ▏ abcdef ▏ Or, at 38 columns: echo 'The quick brown fox jumps over the lazy dog.' | GREP_COLORS='ms=1;91' grep z The quick brown fox jumps over the la ▏ y dog. ▏
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#4440