You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot use left/right arrow keys to edit text in Console.ReadLine on Unix #38051
On Windows, using the left/right arrow keys lets you modify the middle of a set of text from Console.ReadLine without having to delete any of it. However, on MacOS this feature is missing, making it so that you have to delete part of the text in order to modify other parts of it.
Configuration
Found with MacOS, not tested with Linux. Windows has this functionality already.
changed the title [-]Cannot use left/right arrow keys to exit text in Console.ReadLine on MacOS[/-][+]Cannot use left/right arrow keys to edit text in Console.ReadLine on MacOS[/+]on Jun 17, 2020
changed the title [-]Cannot use left/right arrow keys to edit text in Console.ReadLine on MacOS[/-][+]Cannot use left/right arrow keys to edit text in Console.ReadLine on Unix[/+]on Aug 11, 2020
Update on my fix: I've been able to re-implement my changes from when I did this the first time. I was also able to fix 2 of the regressions that it introduced last time. Currently there's a bug involving wrapping multiple lines that I haven't seen before. Once that's fixed, I think I should be ready for a PR.
There is no perfect solution to this problem, so what we do needs to be a 'good enough'.
One of the challenging cases that should work is: typing wrapped lines at the bottom of the terminal.
I don't think terminals offer a way to detect this wrapping except by determining the cursor position after each key press.
Other challenges include:
Ensure we preserve the prompt that may have been written on the line before the ReadLine call.
Characters that span multiple colums, like emojis.
Handing window resizes. Other apps don't seem to handle this perfect either.
@nickorlow did you make more progress on your fix? How does it work in the above cases?
Activity
stephentoub commentedon Jun 17, 2020
#15711
[-]Cannot use left/right arrow keys to exit text in Console.ReadLine on MacOS[/-][+]Cannot use left/right arrow keys to edit text in Console.ReadLine on MacOS[/+][-]Cannot use left/right arrow keys to edit text in Console.ReadLine on MacOS[/-][+]Cannot use left/right arrow keys to edit text in Console.ReadLine on Unix[/+]carlossanlop commentedon Aug 13, 2021
@adamsitnik @jozkee @stephentoub I'm thinking we should move this to 7.0 for the following reasons:
Does anyone have a strong reason to merge this in 6.0, or can we move it to 7.0?
danmoseley commentedon Aug 13, 2021
Makes sense to me. We have seen subtle regressions in this code in the past.
adamsitnik commentedon Aug 13, 2021
@carlossanlop sounds good to me, thanks for trying!
nickorlow commentedon Apr 5, 2023
Hey maintainers cc: @stephentoub @jeffschwMSFT
I figured I'd take another stab at this since it seems like nobody is working on it right now
adamsitnik commentedon May 19, 2023
@nickorlow Awesome! Please let us know if you need any help!
nickorlow commentedon Jun 7, 2023
Update on my fix: I've been able to re-implement my changes from when I did this the first time. I was also able to fix 2 of the regressions that it introduced last time. Currently there's a bug involving wrapping multiple lines that I haven't seen before. Once that's fixed, I think I should be ready for a PR.
tmds commentedon Nov 29, 2023
I was hoping PowerShell
ReadLineFromConsolewould have a good solution for this and other improvements to ReadLine (#94860), but after looking further into it I learned PowerShell actually uses https://github.com/PowerShell/PSReadLine.There is no perfect solution to this problem, so what we do needs to be a 'good enough'.
One of the challenging cases that should work is: typing wrapped lines at the bottom of the terminal.
I don't think terminals offer a way to detect this wrapping except by determining the cursor position after each key press.
Other challenges include:
@nickorlow did you make more progress on your fix? How does it work in the above cases?