Skip to content

Feature/cancel prompt#2028

Merged
patriksvensson merged 2 commits intospectreconsole:mainfrom
red-stronghold:feature/cancel-prompt
Mar 3, 2026
Merged

Feature/cancel prompt#2028
patriksvensson merged 2 commits intospectreconsole:mainfrom
red-stronghold:feature/cancel-prompt

Conversation

@red-stronghold
Copy link
Copy Markdown
Contributor

@red-stronghold red-stronghold commented Feb 25, 2026

Fixes #851
Fixes #1392

  • I have read the Contribution Guidelines
  • I have checked that there isn't already another pull request that solves the above issue
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors

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.

This is a re-make of the closed PR #1919
The old PR was closed due to time.
reason


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

@github-actions github-actions bot added the ⭐ top pull request Top pull request. label Feb 26, 2026
@red-stronghold
Copy link
Copy Markdown
Contributor Author

Sorry about all the merges.

@patriksvensson patriksvensson force-pushed the feature/cancel-prompt branch from 599be75 to ceb4f46 Compare March 3, 2026 16:33
@patriksvensson
Copy link
Copy Markdown
Contributor

@red-stronghold I rebased your PR for you. Will review soon.

Copy link
Copy Markdown
Contributor

@patriksvensson patriksvensson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@patriksvensson patriksvensson merged commit ac98b3d into spectreconsole:main Mar 3, 2026
3 checks passed
@patriksvensson
Copy link
Copy Markdown
Contributor

Merged! Thank you for your contribution. Much appreciated! 👍

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