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

Map special characters in KeyPressPattern #199

Merged
merged 1 commit into from
May 14, 2022

Conversation

waf
Copy link
Owner

@waf waf commented May 14, 2022

KeyPressPattern can either be a ConsoleKey or a char -- in the ConsoleKey case this PR adds a 'best effort' conversion of the ConsoleKey to a char. This is very similar to the conversion that PSReadLine does, so although this is merely best effort I think it should be sufficient.

This change is ultimately required by CSharpRepl because the Roslyn Completion API works on characters (example), not ConsoleKey, so to do some configuration of the Roslyn Completion API we need to know the character that the user has configured for completion, not just the ConsoleKey.

KeyPressPattern can either be a `ConsoleKey` or a `char` -- in the ConsoleKey case this PR adds a 'best effort' conversion of the ConsoleKey to a char. This is very similar to the [conversion that PSReadLine does](https://github.com/PowerShell/PSReadLine/blob/ad74cef2501709d2a60a58f61d7cac32d185209f/PSReadLine/Keys.cs#L31-L58), so although this is merely best effort I think it should be sufficient.

This change is ultimately required by CSharpRepl because the Roslyn Completion API works on characters ([example](https://github.com/dotnet/roslyn/blob/777f4e0a58eda195a6c66a0327267b16bbbf8f9d/src/EditorFeatures/Core/IntelliSense/AsyncCompletion/Helpers.cs#L77-L134)), not ConsoleKey, so to do some configuration of the Roslyn Completion API we need to know the character that the user has configured for completion, not just the ConsoleKey.
@codecov-commenter
Copy link

Codecov Report

Merging #199 (f61cb3d) into main (6daf0d3) will decrease coverage by 0.0%.
The diff coverage is 76.4%.

@@           Coverage Diff           @@
##            main    #199     +/-   ##
=======================================
- Coverage   89.1%   89.0%   -0.1%     
=======================================
  Files         39      39             
  Lines       2786    2798     +12     
  Branches     427     428      +1     
=======================================
+ Hits        2483    2492      +9     
- Misses       197     199      +2     
- Partials     106     107      +1     
Impacted Files Coverage Δ
src/PrettyPrompt/Console/KeyPressPatterns.cs 55.5% <75.0%> (ø)
src/PrettyPrompt/Console/KeyPressPattern.cs 74.3% <76.9%> (+0.2%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6daf0d3...f61cb3d. Read the comment docs.

@waf waf merged commit c33c064 into main May 14, 2022
@waf waf deleted the map-special-characters-in-keypresspattern branch May 14, 2022 06:45
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

2 participants