Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour of Delete Line and Insert Line when used above the top margin #141

Closed
j4james opened this issue Mar 28, 2018 · 5 comments
Assignees
Labels
Area-VT Virtual Terminal sequence support Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Conhost For issues in the Console codebase Resolution-Fix-Available It's available in an Insiders build or a release Work-Item It's being tracked by an actual work item internally. (to be removed soon)
Milestone

Comments

@j4james
Copy link
Collaborator

j4james commented Mar 28, 2018

  • Your Windows build number:

Microsoft Windows [Version 10.0.16299.309]

  • What you're doing and what's happening:

I was curious to see how the Delete Line (\033[M) and Insert Line (\033[L) escape sequences would behave when applied above the top margin of the scrolling region. So as a test, I labelled the first 8 lines of the screen with the numbers 1 to 8, set the top margin to line 4, then attempted to delete line 1.

This was the command I used:

printf "\033c1\n2\n3\n4\n5\n6\n7\n8\033[4r\033[H\033[M\033[r" && read -n 1

And this was the output I saw:

1
2
3
8

Instead of 1 row being deleted from line 1, I got 4 rows deleted from line 4.

I then tried the same thing with the Insert Line sequence:

printf "\033c1\n2\n3\n4\n5\n6\n7\n8\033[4r\033[H\033[L\033[r" && read -n 1

And the output this time was:

1
2
3
6
7
8

Instead of 1 row being inserted at line 1, I got 2 rows deleted from line 4!

  • What's wrong / what should be happening instead:

I don't think there is necessarily a "correct" behaviour in this situation, but I do think the current Windows behaviour is probably a bug.

One possible option would be to ignore these commands when used outside the defined margins (which I think is what XTerm does). Another option would be to handle the insert and delete as if the top margin had not been set, but still constrain the scrolling region within the bottom margin (which is how the Linux console behaves). Either choice would be preferable to the current behaviour.

@zadjii-msft
Copy link
Member

Boy I do love bugs with great straightforward repros. I also really love x forwarding working in WSL, because this becomes a really easy question to answer:

image

Clearly, we're not doing the right thing here. Even if there isn't a documented "right" way to do something, we're treating whatever xterm does as the right way

Filing a bug to address this.

@zadjii-msft zadjii-msft self-assigned this Mar 28, 2018
@zadjii-msft zadjii-msft added Work-Item It's being tracked by an actual work item internally. (to be removed soon) Product-Conhost For issues in the Console codebase labels Mar 28, 2018
@zadjii-msft zadjii-msft added this to the RS5 milestone Mar 28, 2018
@DHowett-MSFT
Copy link
Contributor

It looks like we're still doing something strange here, but it's not nearly as strange as it used to be!

first case

(conhost on left, putty on right)
image

second case

image

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label May 17, 2019
@miniksa miniksa added Area-VT Virtual Terminal sequence support Issue-Bug It either shouldn't be doing this or needs an investigation. labels May 29, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 29, 2019
@bitcrazed bitcrazed modified the milestones: RS5, 20H1 Aug 29, 2019
@zadjii-msft zadjii-msft added this to Unprioritized in 20H1 Priority via automation Aug 29, 2019
@zadjii-msft zadjii-msft moved this from Unprioritized to P2 in 20H1 Priority Aug 29, 2019
@zadjii-msft
Copy link
Member

@j4james You're kinda going wild on the scrolling margins style bugs right now, you want me to give you this one too?

@j4james
Copy link
Collaborator Author

j4james commented Sep 4, 2019

Ah yes, I've been meaning to come back to this. I think what we have now is actually the correct behaviour and we can close this issue.

Here's what the DEC STD 070 manual has to say about the Insert Line command:

Only that portion of the display between the top, bottom, left, and right margins is affected. IL is ignored if the Active Position is outside the Scroll Area.

Similarly for the Delete Line command:

Only that portion of the display between the top, bottom, left, and right margins is affected. DL is ignored if the active position is outside the scroll area.

So both of the test cases above should leave the numbers unchanged after the IL or DL since the cursor position is above the top margin. And that's how XTerm interprets it too:

image

So I think putty has probably got this wrong, and if we're matching XTerm then we've got it right.

@DHowett-MSFT
Copy link
Contributor

Really happy to hear that. Thank you!

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Sep 4, 2019
@DHowett-MSFT DHowett-MSFT added Resolution-Fix-Available It's available in an Insiders build or a release and removed Needs-Tag-Fix Doesn't match tag requirements labels Sep 4, 2019
@DHowett-MSFT DHowett-MSFT removed this from P2 in 20H1 Priority Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-VT Virtual Terminal sequence support Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Conhost For issues in the Console codebase Resolution-Fix-Available It's available in an Insiders build or a release Work-Item It's being tracked by an actual work item internally. (to be removed soon)
Projects
None yet
Development

No branches or pull requests

5 participants