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

Cannot use left/right arrow keys to edit text in Console.ReadLine on Unix #38051

Open
Tracked by #64487
nickorlow opened this issue Jun 17, 2020 · 9 comments
Open
Tracked by #64487
Assignees
Labels
area-System.Console enhancement Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@nickorlow
Copy link
Contributor

Description

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.

I intend to attempt to fix this.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Console untriaged New issue has not been triaged by the area owner labels Jun 17, 2020
@ghost
Copy link

ghost commented Jun 17, 2020

Tagging subscribers to this area: @eiriktsarpalis
Notify danmosemsft if you want to be subscribed.

@stephentoub
Copy link
Member

#15711

@nickorlow nickorlow 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 Jun 17, 2020
@adamsitnik adamsitnik removed the untriaged New issue has not been triaged by the area owner label Jun 24, 2020
@adamsitnik adamsitnik added this to the 5.0.0 milestone Jun 24, 2020
@eiriktsarpalis eiriktsarpalis modified the milestones: 5.0.0, 6.0.0 Aug 11, 2020
@eiriktsarpalis eiriktsarpalis added the enhancement Product code improvement that does NOT require public API changes/additions label Aug 11, 2020
@eiriktsarpalis eiriktsarpalis 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 Aug 11, 2020
@carlossanlop
Copy link
Member

@adamsitnik @jozkee @stephentoub I'm thinking we should move this to 7.0 for the following reasons:

  • PR Console.Unix: support backspace during Console.Read #49649 was looking to fix this. The original contributor could not continue working on it, but @eiriktsarpalis and @nickorlow took over and pushed some additional commits to the PR.
  • Unfortunately, some OSX regressions were introduced with those last commits, which still need to be investigated and fixed.
  • @tmds merged PR Console.Unix: support backspace during Console.Read #49649 a few days ago, which heavily modified code that this issue's PR is also touching.
  • I am currently reviewing both PRs to understand how to merge them, but I'm noticing it's not trivial.
  • The change affects all platforms, and manual testing is required to verify this fix.
  • I am not sure we will have enough time to get feedback from the community to ensure we didn't introduce regressions.

Does anyone have a strong reason to merge this in 6.0, or can we move it to 7.0?

@danmoseley
Copy link
Member

Makes sense to me. We have seen subtle regressions in this code in the past.

@adamsitnik
Copy link
Member

@carlossanlop sounds good to me, thanks for trying!

@adamsitnik adamsitnik modified the milestones: 6.0.0, 7.0.0 Aug 13, 2021
@jeffhandley jeffhandley modified the milestones: 7.0.0, Future Jul 9, 2022
@carlossanlop carlossanlop removed their assignment Mar 23, 2023
@carlossanlop carlossanlop added the untriaged New issue has not been triaged by the area owner label Mar 23, 2023
@jeffschwMSFT jeffschwMSFT removed the untriaged New issue has not been triaged by the area owner label Apr 4, 2023
@nickorlow
Copy link
Contributor Author

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
Copy link
Member

I figured I'd take another stab at this since it seems like nobody is working on it right now

@nickorlow Awesome! Please let us know if you need any help!

@nickorlow
Copy link
Contributor Author

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
Copy link
Member

tmds commented Nov 29, 2023

I was hoping PowerShell ReadLineFromConsole would 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:

  • 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Console enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

No branches or pull requests

10 participants