Skip to content

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

Open

Description

@nickorlow

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.

Activity

  1. added
    untriaged
    on Jun 17, 2020
  2. stephentoub commented on Jun 17, 2020

    @stephentoub
    Member
  3. 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
  4. removed
    untriaged
    on Jun 24, 2020
  5. added this to the 5.0.0 milestone on Jun 24, 2020
  6. modified the milestones: 5.0.0, 6.0.0 on Aug 11, 2020
  7. added
    enhancement
    on Aug 11, 2020
  8. 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
  9. carlossanlop commented on Aug 13, 2021

    @carlossanlop
    Contributor

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

  10. danmoseley commented on Aug 13, 2021

    @danmoseley
    Contributor

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

  11. adamsitnik commented on Aug 13, 2021

    @adamsitnik
    Member

    @carlossanlop sounds good to me, thanks for trying!

  12. modified the milestones: 6.0.0, 7.0.0 on Aug 13, 2021
  13. modified the milestones: 7.0.0, Future on Jul 9, 2022
  14. removed their assignment
    on Mar 23, 2023
  15. added
    untriaged
    on Mar 23, 2023
  16. removed
    untriaged
    on Apr 4, 2023
  17. nickorlow commented on Apr 5, 2023

    @nickorlow
    ContributorAuthor

    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

  18. adamsitnik commented on May 19, 2023

    @adamsitnik
    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!

  19. nickorlow commented on Jun 7, 2023

    @nickorlow
    ContributorAuthor

    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.

  20. tmds commented on Nov 29, 2023

    @tmds
    Member

    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

Metadata

Metadata

Assignees

Labels

area-System.Consoleenhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions