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

Select value - issue in terminal #1114

Closed
ivodolenc opened this issue May 16, 2022 · 4 comments
Closed

Select value - issue in terminal #1114

ivodolenc opened this issue May 16, 2022 · 4 comments
Labels

Comments

@ivodolenc
Copy link

Hi, nice work on inquirer!

When I select value everything works great (example bellow), but when I exit/interrupt process, for example control + c, then cursor and last value (Major) disappears from vscode terminal.

const select = require('@inquirer/select')

const selectVersion = async () => {
  const answer = await select({
    message: 'Select new version:',
    choices: [
      { name: 'Patch', value: 'patch' },
      { name: 'Minor', value: 'minor' },
      { name: 'Major', value: 'major' }
    ]
  })

  console.log(`New version: ${answer}`) // Works normal after selecting
}

However, this example works normal on selecting and exit:

const inquirer = require('inquirer')

inquirer
  .prompt([
    {
      type: 'list',
      name: 'version',
      message: 'Select new version:',
      choices: [
        { name: 'Patch', value: 'patch' },
        { name: 'Minor', value: 'minor' },
        { name: 'Major', value: 'major' }
      ]
    }
  ])
  .then(answers => {
    console.log(`New version: ${answers.version}`)
  })

Do you have any idea what it might be the issue?

@SBoudrias SBoudrias added the bug label May 20, 2022
@SBoudrias
Copy link
Owner

Hey, thanks for the heads up. It's possible in the new core we do not print an empty line or reset the cursor position on exit.

The issue would live inside https://github.com/SBoudrias/Inquirer.js/tree/master/packages/core - you can compare to the previous implementation looking for exit listeners and what they do.

@ivodolenc
Copy link
Author

Ok thanks for the feedback! It’s not urgent so I’m using a working (second) example at the moment!

@ivodolenc
Copy link
Author

Hi, I just tested this and it seems the problem is still the same, after pressing control + c (on mac) to exit, the cursor disappears in the terminal.

Versions

  • macos: ventura latest
  • node: 18.17.1
  • npm: 9.8.1
  • @inquirer/select: 1.2.9

Reproduction

  1. Install @inquirer/select
  2. Add the code from the official Usage example
  3. Run it!

The code works fine, but if I manually cancel/quit process, the cursor disappears so I can't see it anymore and need to restart the terminal.

@SBoudrias SBoudrias reopened this Sep 1, 2023
@SBoudrias
Copy link
Owner

This should now work properly.

Not sure how it happens, but signals became 0 without names (just null.) And so the force exit handler wasn't running anymore. It could be a side-effect of the Node async hooks; but really weird. Anyway, now detection should be more reliable for the future.

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

No branches or pull requests

3 participants