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

Ignore keys with no valid KeyChar for vi movements #3928

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thomazmoura
Copy link

@thomazmoura thomazmoura commented Jan 25, 2024

PR Summary

Add a new function called ReadKeyChar that loops until a key with valid KeyChar is read. Change the calls for ReadKey().KeyChar on .vi.cs files so that vi movements have this new behaviour.

The idea is to fix issues on Windows like not being able to move to characters that are behind dead keys on layouts such as US-international (single quotes, for example, is input only after hitting single quote and then space). The current behavior on Windows breaks the chain by returning a PSKeyInfo without a valid KeyChar and then trying to move to it (instead of waiting for the next key press to get the actual input).

PR Checklist

  • [ X ] PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • [ X ] Summarized changes
  • Make sure you've added one or more new tests
  • [ X ] Make sure you've tested these changes in terminals that PowerShell is commonly used in (i.e. conhost.exe, Windows Terminal, Visual Studio Code Integrated Terminal, etc.)
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed at PowerShell-Docs
      • Doc Issue filed:

I'm not really sure how to unit test it since it seems dependent on the keyboard layout, but I welcome suggestions.

So far I've manually tested it on Windows running PowerShell 7.4.1 with Windows Terminal, conhost and Visual Studio Code and Linux (WSL2) with Windows Terminal.

The only caveaut I've found so far is that function keys (such as F1~F12) will also be ignored, But since the only code that is being changed to use the new version are the vi movement ones I believe this is not an issue.

Microsoft Reviewers: Open in CodeFlow

@thomazmoura
Copy link
Author

@thomazmoura please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@thomazmoura thomazmoura changed the title Ignore keys with no valid KeyChar for vi movements (#3795) Ignore keys with no valid KeyChar for vi movements Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant