Deleting in command line and using a right arrow goes past the end of the line #23645

Closed
opened 2026-01-31 08:48:04 +00:00 by claunia · 1 comment
Owner

Originally created by @al20878 on GitHub (Sep 25, 2025).

Windows Terminal version

1.22.12111.0

Windows build number

10.0.19045.6332

Other Software

No response

Steps to reproduce

I'm using CMD mode for commands. Enter any reasonable text resembling a command (does not even have to be a real command). Then press the Enter key.

Use the Up Arrow key to recall the previous input, and then use the Left Arrow key to go somewhere in the middle of the recalled string, and use the Backspace key to delete one character.

Now start using the Right Arrow key to move the cursor towards the end of the command. Once you move past the last character, it will get doubled. I suppose that's because internally, the deletion of the character in the middle did not discount the overall command line length, so the character moved out of the last position (to the right) got "resurrected".

I can reliably reproduce this behavior every time, so I suspect that's a bug. Enter "abcdefgh", then recall it:

c:\>abcdefgh

Use Left arrow used to move under "f" and then Backspace twice to delete the "de", then the Right Arrow used to move the cursor to the end of the line as long as it can go. The result:

c:\>abcfghgh

(the two last characters "gh" were duplicated/resurrected as the cursor moved past "abcfgh").

P.S. As I was submitting this report, it turned out that you don't have to actually recall the command. Even deleting in the newly entered text results in the same behavior when the cursor gets pushed towards the end of the line.

Expected Behavior

Expected behavior: the cursor should not move past the original "gh". That is, even when moved all the way to the end, the command should look like:

c:\>abcfgh

Actual Behavior

See above

Originally created by @al20878 on GitHub (Sep 25, 2025). ### Windows Terminal version 1.22.12111.0 ### Windows build number 10.0.19045.6332 ### Other Software _No response_ ### Steps to reproduce I'm using CMD mode for commands. Enter any reasonable text resembling a command (does not even have to be a real command). Then press the Enter key. Use the Up Arrow key to recall the previous input, and then use the Left Arrow key to go somewhere in the middle of the recalled string, and use the Backspace key to delete one character. Now start using the Right Arrow key to move the cursor towards the end of the command. Once you move _past_ the last character, it will get doubled. I suppose that's because internally, the deletion of the character in the middle did not discount the overall command line length, so the character moved out of the last position (to the right) got "resurrected". I can reliably reproduce this behavior every time, so I suspect that's a bug. Enter "abcdefgh", then recall it: ``` c:\>abcdefgh ``` Use Left arrow used to move under "f" and then Backspace twice to delete the "de", then the Right Arrow used to move the cursor to the end of the line as long as it can go. The result: ``` c:\>abcfghgh ``` (the two last characters "gh" were duplicated/resurrected as the cursor moved past "abcfgh"). P.S. As I was submitting this report, it turned out that you don't have to actually recall the command. Even deleting in the newly entered text results in the same behavior when the cursor gets pushed towards the end of the line. ### Expected Behavior Expected behavior: the cursor should not move past the original "gh". That is, even when moved all the way to the end, the command should look like: ``` c:\>abcfgh ``` ### Actual Behavior See above
claunia added the Resolution-By-DesignNeeds-TriageIssue-Bug labels 2026-01-31 08:48:05 +00:00
Author
Owner

@DHowett commented on GitHub (Sep 25, 2025):

So! This is actually a really fun "feature" of CMD that we'll never be able to change (since folks get very testy when we break their muscle memory.)

CMD lets you recall the last command character-by-character by navigating off the right end of the line. It's good for ... something? Like writing a command like dir onefile twofile and then changing up some of the parameters and recalling the rest?

If it was once a bug, it's existed long enough to be expected behavior under Hyrum's law at least. 🙂

@DHowett commented on GitHub (Sep 25, 2025): So! This is actually a really fun "feature" of CMD that we'll never be able to change (since folks get very testy when we break their muscle memory.) CMD lets you recall the last command character-by-character by navigating off the right end of the line. It's good for ... something? Like writing a command like `dir onefile twofile` and then changing up some of the parameters and recalling the rest? If it was once a bug, it's existed long enough to be expected behavior under Hyrum's law at least. 🙂
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23645