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

Escape key behaves like Enter in interactive mode #236

Open
5 of 7 tasks
qadzek opened this issue Sep 28, 2024 · 3 comments
Open
5 of 7 tasks

Escape key behaves like Enter in interactive mode #236

qadzek opened this issue Sep 28, 2024 · 3 comments

Comments

@qadzek
Copy link

qadzek commented Sep 28, 2024

Describe the bug

Thank you for this wonderful tool.

When I run a command that allows me to make a selection interactively (e.g. nr) and I change my mind, I hit the Escape key, expecting to return to the command line. However, instead of returning, the selected script is executed, just as if I had hit Enter.

The only difference between hitting Enter and Escape is that in the former case ✔ script to run › test is displayed, while in the latter ✖ script to run › test appears. In both cases the script is run.

Reproduction

Seems not applicable

System Info

This occurs both on a workstation and a VPS. For instance:

System:
  OS: Linux 6.5 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
  CPU: (2) x64 AMD EPYC 7551 32-Core Processor
  Memory: 262.68 MB / 947.50 MB
  Container: Yes
  Shell: 5.8.1 - /usr/bin/zsh
Binaries:
  Node: 20.17.0 - /usr/bin/node
  npm: 10.8.2 - /usr/bin/npm
Browsers:
  Chromium: 128.0.6613.137

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributions

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
@antfu
Copy link
Member

antfu commented Sep 29, 2024

PR welcome, thanks!

@babu-ch
Copy link

babu-ch commented Oct 3, 2024

I think this is probably related 👀
terkelg/prompts#369

@noootwo
Copy link

noootwo commented Nov 5, 2024

I think this is probably related 👀 terkelg/prompts#369

I think so, but theprompts seems to be almost non-maintainable, there are about three solutions:

  1. Listen for the 'escape' event and exit the process (which may cause other interaction problems, not recommended)
  2. Fork the prompt repo and fix this issue
  3. Switch to a command-line interactive library (such as Inquirer)

If there is a feasible solution, I think I can work for it. @antfu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants