IL and DL commands should move cursor to left margin #3552

Closed
opened 2026-01-30 23:24:10 +00:00 by claunia · 8 comments
Owner

Originally created by @j4james on GitHub (Aug 24, 2019).

Originally assigned to: @j4james on GitHub.

Environment

Windows build number: Version 10.0.18362.239

Steps to reproduce

Open a WSL shell and execute the following command:

printf "\e[10G\e[LLeft Margin?\n"

What that is doing is moving the cursor to column 10, inserting a line with the IL escape sequence, and then writing out "Left Margin?".

Expected behavior

The IL escape sequence should force the cursor to move back to column 1, so the text should appear at the left margin. This is what is looks in XTerm:

image

For further confirmation that this is the correct behaviour, this is what DEC STD 070 reference manual says regarding in the Insert Line escape sequence:

The Active Position is set to the Left Margin in the active line after execution of this control. The active line does not change.

Actual behavior

The cursor remains in column 10 after the insert, so the text appears in the wrong location:

image

The DL (Delete Line) escape sequence has the exact same problem. It should move the cursor back to the left margin, but in the Windows console it doesn't.

Originally created by @j4james on GitHub (Aug 24, 2019). Originally assigned to: @j4james on GitHub. # Environment ```none Windows build number: Version 10.0.18362.239 ``` # Steps to reproduce Open a WSL shell and execute the following command: printf "\e[10G\e[LLeft Margin?\n" What that is doing is moving the cursor to column 10, inserting a line with the [IL](https://vt100.net/docs/vt510-rm/IL.html) escape sequence, and then writing out "Left Margin?". # Expected behavior The IL escape sequence should force the cursor to move back to column 1, so the text should appear at the left margin. This is what is looks in XTerm: ![image](https://user-images.githubusercontent.com/4181424/63637587-a8625280-c675-11e9-9bd1-9b6a0e2f4abf.png) For further confirmation that this is the correct behaviour, this is what DEC STD 070 reference manual says regarding in the _Insert Line_ escape sequence: > The Active Position is set to the Left Margin in the active line after execution of this control. The active line does not change. # Actual behavior The cursor remains in column 10 after the insert, so the text appears in the wrong location: ![image](https://user-images.githubusercontent.com/4181424/63637590-bb752280-c675-11e9-9932-b74042e3034a.png) The DL (Delete Line) escape sequence has the exact same problem. It should move the cursor back to the left margin, but in the Windows console it doesn't.
Author
Owner

@j4james commented on GitHub (Aug 24, 2019):

The fix for this is fairly straightforward. My suggestion would be calling SetConsoleCursorPositionImpl after the call to ScrollConsoleScreenBufferWImpl in the DoSrvPrivateModifyLinesImpl function (which is where both the IL and DL escape sequences are ultimately handled). It has to be done inside the IsCursorInMargins check, since the cursor is not supposed to be moved if it was outside the margin boundaries.

I was considering adding this fix as part of PR #2505, since I first noticed the behaviour while testing those changes, and this fix is going to require updates to some of those testcases. I can do a separate PR for it, if that's preferable, but that can't really be done until after PR #2505 is merged.

@j4james commented on GitHub (Aug 24, 2019): The fix for this is fairly straightforward. My suggestion would be calling `SetConsoleCursorPositionImpl` after the call to `ScrollConsoleScreenBufferWImpl` in the [`DoSrvPrivateModifyLinesImpl`](https://github.com/microsoft/terminal/blob/0e6f290806ef066e8ef29c0a933c83a0007eac98/src/host/getset.cpp#L2029-L2065) function (which is where both the IL and DL escape sequences are ultimately handled). It has to be done inside the `IsCursorInMargins` check, since the cursor is not supposed to be moved if it was outside the margin boundaries. I was considering adding this fix as part of PR #2505, since I first noticed the behaviour while testing those changes, and this fix is going to require updates to some of those testcases. I can do a separate PR for it, if that's preferable, but that can't really be done until after PR #2505 is merged.
Author
Owner

@ramsay-vibes commented on GitHub (Aug 24, 2019):

I executed the same command in an Ubuntu shell outside the Terminal environment:

printf "\e[10G\e[LLeft Margin?\n"

Interestingly, it formatted the text exactly the same as the issue reported above, using Ubuntu shell inside Terminal.

ubuntu

@ramsay-vibes commented on GitHub (Aug 24, 2019): I executed the same command in an Ubuntu shell outside the Terminal environment: `printf "\e[10G\e[LLeft Margin?\n"` Interestingly, it formatted the text exactly the same as the issue reported above, using Ubuntu shell inside Terminal. ![ubuntu](https://user-images.githubusercontent.com/8571098/63638318-9933d280-c67e-11e9-9b40-a50bd90bf55c.jpg)
Author
Owner

@DHowett-MSFT commented on GitHub (Aug 24, 2019):

@j4james good catch! I imagine we also do the wrong thing with DECLRMM + DECSLRM (CSI Pl ; Pr s) + IL?

@encladeus Terminal and Console use the same VT handling infrastructure, so that is not terribly surprising!

@DHowett-MSFT commented on GitHub (Aug 24, 2019): @j4james good catch! I imagine we also do the wrong thing with DECLRMM + DECSLRM (`CSI Pl ; Pr s`) + IL? @encladeus Terminal and Console use the same VT handling infrastructure, so that is not terribly surprising!
Author
Owner

@DHowett-MSFT commented on GitHub (Aug 24, 2019):

Actually, it looks like we don't support DECLRMM or DECSLRM 😄 We'll need to care about this once we do, probably.

@DHowett-MSFT commented on GitHub (Aug 24, 2019): Actually, it looks like we don't support `DECLRMM` or `DECSLRM` :smile: We'll need to care about this once we do, probably.
Author
Owner

@j4james commented on GitHub (Aug 25, 2019):

Yeah, I've been ignoring DECSLRM. I don't think it's widely supported, and will probably require quite a lot of work to implement - there are a lot of sequences that are going to be affected by it. Personally I'd want to get the lower conformance levels under control first.

@j4james commented on GitHub (Aug 25, 2019): Yeah, I've been ignoring `DECSLRM`. I don't think it's widely supported, and will probably require quite a lot of work to implement - there are a lot of sequences that are going to be affected by it. Personally I'd want to get the lower conformance levels under control first.
Author
Owner

@DHowett-MSFT commented on GitHub (Aug 26, 2019):

Tagged up. Good investigation!

@DHowett-MSFT commented on GitHub (Aug 26, 2019): Tagged up. Good investigation!
Author
Owner

@ghost commented on GitHub (Sep 24, 2019):

:tada:This issue was addressed in #2731, which has now been successfully released as Windows Terminal Preview v0.5.2661.0.🎉

Handy links:

@ghost commented on GitHub (Sep 24, 2019): :tada:This issue was addressed in #2731, which has now been successfully released as `Windows Terminal Preview v0.5.2661.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v0.5.2661.0) * [Store Download](https://www.microsoft.com/store/apps/9n0dx20hk701?cid=storebadge&ocid=badge)
Author
Owner

@christianparpart commented on GitHub (Sep 26, 2019):

Yeah, I've been ignoring DECSLRM. I don't think it's widely supported, and will probably require quite a lot of work to implement - there are a lot of sequences that are going to be affected by it. Personally I'd want to get the lower conformance levels under control first.

Actually, I just came here because I wanted to check whether DECSLRM already in dev in Windows-Terminal.

However, I just wanted to drop the note, that TMUX (widely used) is actually making use of DECSLRM, whereas DECSTBM is (e.g.) also used in htop (for scrolling lines down/up).

@christianparpart commented on GitHub (Sep 26, 2019): > Yeah, I've been ignoring `DECSLRM`. I don't think it's widely supported, and will probably require quite a lot of work to implement - there are a lot of sequences that are going to be affected by it. Personally I'd want to get the lower conformance levels under control first. Actually, I just came here because I wanted to check whether DECSLRM already in dev in Windows-Terminal. However, I just wanted to drop the note, that TMUX (widely used) is actually making use of DECSLRM, whereas DECSTBM is (e.g.) also used in htop (for scrolling lines down/up).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#3552