HOME / Ctrl+u behav stops in a middle of the line (END overruns EOL) #14392

Closed
opened 2026-01-31 04:09:05 +00:00 by claunia · 2 comments
Owner

Originally created by @gituliar on GitHub (Jul 3, 2021).

Windows Terminal version (or Windows build number)

10.0.19042.1052

Other Software

Windows Terminal Version: 1.8.1444.0

[sasha@p14s Sources]$ echo $PS1
\e[0;32m[\u@\h \e[0;33m\W\e[0;32m]$ \e[0m

Steps to reproduce

HomeEnd_issue

Expected Behavior

  • Ctrl+u combination to remove a whole line, given a cursor is at EOL
  • HOME key to place cursor in the beginning of a line
  • END key to place cursor in the end of a line

Actual Behavior

  • On HOME / Ctrl+u cursor is stuck in the middle of the line
  • On END key press cursor overruns EOL
Originally created by @gituliar on GitHub (Jul 3, 2021). ### Windows Terminal version (or Windows build number) 10.0.19042.1052 ### Other Software Windows Terminal Version: 1.8.1444.0 [sasha@p14s Sources]$ echo $PS1 `\e[0;32m[\u@\h \e[0;33m\W\e[0;32m]$ \e[0m` ### Steps to reproduce ![HomeEnd_issue](https://user-images.githubusercontent.com/439048/124362553-e3504c80-dc35-11eb-8583-054218f15f25.gif) ### Expected Behavior * Ctrl+u combination to remove a whole line, given a cursor is at EOL * HOME key to place cursor in the beginning of a line * END key to place cursor in the end of a line ### Actual Behavior * On HOME / Ctrl+u cursor is stuck in the middle of the line * On END key press cursor overruns EOL
claunia added the Needs-TriageNeeds-Tag-FixNeeds-Attention labels 2026-01-31 04:09:05 +00:00
Author
Owner

@DHowett commented on GitHub (Jul 3, 2021):

I suspect that this is because your prompt contains unguarded control sequences. Bash attempts to measure the prompt, but it does not know that control sequences do not contribute to the width.

This will also cause the line to be wrapped before it reaches the edge of the screen.

If you put a \[ and \] pair on opposite sides of every control sequence in your prompt, does it go back to working correctly?

For completeness' sake: this isn't a terminal issue, and you can find more information in this StackOverflow post.

@DHowett commented on GitHub (Jul 3, 2021): I suspect that this is because your prompt contains unguarded control sequences. Bash attempts to measure the prompt, but it does not know that control sequences do not contribute to the width. This will also cause the line to be wrapped before it reaches the edge of the screen. If you put a `\[` and `\]` pair on opposite sides of every control sequence in your prompt, does it go back to working correctly? For completeness' sake: this isn't a terminal issue, and you can find more information in [this StackOverflow post](https://unix.stackexchange.com/questions/105958/terminal-prompt-not-wrapping-correctly).
Author
Owner

@gituliar commented on GitHub (Jul 3, 2021):

@DHowett many thanks for a quick feedback and details!

Indeed, escaping control sequences for PS1 did help.

PS. Thought this is a Terminal's issue since never faced this in other terminals.

@gituliar commented on GitHub (Jul 3, 2021): @DHowett many thanks for a quick feedback and details! Indeed, escaping control sequences for PS1 did help. PS. Thought this is a Terminal's issue since never faced this in other terminals.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14392