Conversation
Co-authored-by: shibayan <1356444+shibayan@users.noreply.github.com>
…, ESC key, fixed lifecycle Co-authored-by: shibayan <1356444+shibayan@users.noreply.github.com>
|
@copilot Please resolve conflicts |
…#332) with ConsoleKeyBinding architecture Co-authored-by: shibayan <1356444+shibayan@users.noreply.github.com>
Conflicts resolved in |
There was a problem hiding this comment.
Pull request overview
Refactors Sharprompt’s form key-handling to use a (ConsoleKey, ConsoleModifiers) value type for bindings, simplifying handler signatures and adding Esc as an additional cancellation key while aligning with the newer PromptConfiguration-based form architecture.
Changes:
- Introduces
ConsoleKeyBindingand migrates form key-handler maps toDictionary<ConsoleKeyBinding, Func<bool>>. - Splits plain vs Ctrl+key behaviors into separate handlers (notably for text-editing/navigation).
- Adds unit tests validating
ConsoleKeyBindingequality semantics and dictionary usability.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Sharprompt/Internal/ConsoleKeyBinding.cs | Adds a value type representing a key + modifiers pair for dictionary-based key bindings. |
| Sharprompt/Forms/FormBase.cs | Switches dispatch to binding-based lookup and adds Esc cancellation handler. |
| Sharprompt/Forms/TextFormBase.cs | Registers discrete bindings/handlers for plain vs Ctrl navigation/editing keys. |
| Sharprompt/Forms/SelectFormBase.cs | Updates paginator navigation bindings to use ConsoleKeyBinding. |
| Sharprompt/Forms/PasswordForm.cs | Updates backspace handler registration to new binding/handler signature. |
| Sharprompt/Forms/MultiSelectForm.cs | Updates selection toggle and Ctrl-shortcut bindings to new binding style. |
| Sharprompt/Forms/ListForm.cs | Adjusts delete behavior override to the new Ctrl-specific handler. |
| Sharprompt.Tests/ConsoleKeyBindingTests.cs | Adds tests for ConsoleKeyBinding equality/hash/dictionary behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ConsoleKeyBindingvalue type combiningConsoleKey+ConsoleModifiersfor type-safe key bindingFormBase.KeyHandlerMapsto useConsoleKeyBindingas key andFunc<bool>as handlerTextFormBaseto register separate handlers for plain vs Ctrl+key combinationsSelectFormBase,SelectForm,MultiSelectFormto use the new binding stylePasswordFormandListFormto use new binding styleFormBase.Dispose()ownsIConsoleDriver,OffscreenBufferis not IDisposableFormBaseas an alternative cancellation keyConsoleKeyBindingTests(10 tests)PromptConfigurationrefactor (Refactor prompt options and forms to use PromptConfiguration for improved extensibility #332):SelectFormBase,PromptConfiguration,PromptOptions, updated constructorsOriginal prompt
Created from VS Code.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.