Skip to content

Feature/cancel prompt with esc#1919

Closed
red-stronghold wants to merge 5 commits intospectreconsole:mainfrom
red-stronghold:feature/cancel-prompt-with-esc
Closed

Feature/cancel prompt with esc#1919
red-stronghold wants to merge 5 commits intospectreconsole:mainfrom
red-stronghold:feature/cancel-prompt-with-esc

Conversation

@red-stronghold
Copy link
Copy Markdown
Contributor

@red-stronghold red-stronghold commented Oct 14, 2025

fixes #851
fixes #1392

  • I have read the Contribution Guidelines
  • I have commented on the issue above and discussed the intended changes
  • A maintainer has signed off on the changes and the issue was assigned to me
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors
  • The documentation was modified to reflect the changes OR no documentation changes are required.

Changes

For SelectionPrompt<T>:

  • Allow setting a Func<T> property to be triggered on Cancel
  • Extension methods to set the property, either with a Func or with a Value (for easier use)
  • Capture 'ESC' key and cancel the prompt
  • Return the specified result if the prompt is cancelled
  • Unit tests to cover both extension methods.

For MultiSelectionPrompt<T>:

  • Allow setting a Func<List<T>> property to be triggered on Cancel
  • Extension methods to set the property, either with a Func, a List, a Value or an empty List (for easier use)
  • Capture 'ESC' key and cancel the prompt
  • Return the specified result if the prompt is cancelled
  • Unit tests to cover all extension methods.

If property not set, the prompts works as before.


Please upvote 👍 this pull request if you are interested in it.

@red-stronghold
Copy link
Copy Markdown
Contributor Author

@red-stronghold 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

@red-stronghold
Copy link
Copy Markdown
Contributor Author

@patriksvensson any chance you (or someone else) can review this?
Or maybe something else is missing. Let me know.
I really want this feature out for my own project. :)

@github-actions github-actions bot added the ⭐ top pull request Top pull request. label Dec 30, 2025
@patriksvensson
Copy link
Copy Markdown
Contributor

Hi!

Thanks so much for taking the time to submit this PR.
I really appreciate the contribution!

Unfortunately, I haven’t had the capacity to review this in a timely manner, and since it was opened, the repository has changed significantly. Because of that, this PR is no longer in a state where it can be reviewed or merged as-is. This is not your fault, but mine, and I'm sorry about this.

I’m going to close it for now to help keep things tidy. That said, if you’re still interested in contributing, please feel free to open a new pull request that’s up to date with the current state of the repository, and I’ll be happy to take a look when I can. I'll promise I'll do better this time around.

Thanks again for your work and for your interest in the project!

@red-stronghold red-stronghold mentioned this pull request Feb 25, 2026
4 tasks
@red-stronghold red-stronghold deleted the feature/cancel-prompt-with-esc branch March 4, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⭐ top pull request Top pull request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow user to cancel input during Prompt() Esc Key to exit selection

2 participants