Unexpected backspace behaviour in the rightmost column of the screen #195

Closed
opened 2026-01-30 21:45:15 +00:00 by claunia · 2 comments
Owner

Originally created by @j4james on GitHub (Mar 15, 2018).

Originally assigned to: @zadjii-msft on GitHub.

  • Your Windows build number:

Microsoft Windows [Version 10.0.16299.248]

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

In older versions of Windows, and DOS, if you output a character in the rightmost column of the screen, the cursor would immediately wrap onto the next line. However, in the new Windows 10 console, the cursor remains where it is after outputting something in the rightmost column - it only wraps onto the next line once you output an additional character. This I assume is intentional behaviour for compatibility with Linux.

What's unexpected, though, is how it behaves when you attempt to move back from this position, either with an ANSI CUB sequence (\033[D) or a backspace. Below are two test cases that move the cursor to the rightmost column, output an x, then attempt to move back one character, before outputting a y.

printf "\033[1000Cx\by\n"
printf "\033[1000Cx\033[Dy\n"

On Linux, both of these sequences result in the characters yx appearing at the end of the line, i.e. both methods move the cursor one column back from the rightmost column when it's in that ambiguous state.

On Windows 10, however, only the CUB sequence produces the yx output. The backspace appears to have no effect, so the y ends up overwriting the x, and you just have the y left at the end of the line.

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

I'd expect the CUB sequence and backspace sequence to behave the same way in this situation, both resulting in yx appearing at the end of the line (the same as Linux).

Originally created by @j4james on GitHub (Mar 15, 2018). Originally assigned to: @zadjii-msft on GitHub. * Your Windows build number: Microsoft Windows [Version 10.0.16299.248] * What you're doing and what's happening: In older versions of Windows, and DOS, if you output a character in the rightmost column of the screen, the cursor would immediately wrap onto the next line. However, in the new Windows 10 console, the cursor remains where it is after outputting something in the rightmost column - it only wraps onto the next line once you output an additional character. This I assume is intentional behaviour for compatibility with Linux. What's unexpected, though, is how it behaves when you attempt to move back from this position, either with an ANSI CUB sequence (`\033[D`) or a backspace. Below are two test cases that move the cursor to the rightmost column, output an `x`, then attempt to move back one character, before outputting a `y`. printf "\033[1000Cx\by\n" printf "\033[1000Cx\033[Dy\n" On Linux, both of these sequences result in the characters `yx` appearing at the end of the line, i.e. both methods move the cursor one column back from the rightmost column when it's in that ambiguous state. On Windows 10, however, only the CUB sequence produces the `yx` output. The backspace appears to have no effect, so the `y` ends up overwriting the `x`, and you just have the `y` left at the end of the line. * What's wrong / what should be happening instead: I'd expect the CUB sequence and backspace sequence to behave the same way in this situation, both resulting in `yx` appearing at the end of the line (the same as Linux).
claunia added the Product-Conhost label 2026-01-30 21:45:15 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Mar 15, 2018):

Huh. I think I know exactly which code handles that. I doubt we considered this particular edge case 😝

I'll file a bug to look at it.

@zadjii-msft commented on GitHub (Mar 15, 2018): Huh. I think I know exactly which code handles that. I doubt we considered this particular _edge_ case 😝 I'll file a bug to look at it.
Author
Owner

@DHowett-MSFT commented on GitHub (Nov 21, 2018):

It looks like this fix shipped in the 1809 update. Thanks for reporting!

@DHowett-MSFT commented on GitHub (Nov 21, 2018): It looks like this fix shipped in the 1809 update. Thanks for reporting!
Sign in to join this conversation.
No Label Product-Conhost
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#195