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

Cursor dissapears after CTRL-C in mocha --watch #2645

Closed
mcortesi opened this issue Dec 21, 2016 · 10 comments
Closed

Cursor dissapears after CTRL-C in mocha --watch #2645

mcortesi opened this issue Dec 21, 2016 · 10 comments
Labels
type: bug a defect, confirmed by a maintainer

Comments

@mcortesi
Copy link

It seems mocha hides the cursor during the run but it forgots to enable it again when a SIGINT is sent...

In my script i had to do:

  process.on('SIGINT', function() {
    // show cursor
    console.log("\x1B[?25h");
    process.exit();
  });
@rzane
Copy link

rzane commented Dec 29, 2016

Yeah, this has been bothering me for a long time. Here's the equivalent bash:

trap 'echo "\x1B[?25h"' INT

@Munter
Copy link
Member

Munter commented Jan 3, 2017

This one has been bothering me a lot as well. I tried to spot what caused it a while ago, but didn't have the time to properly dive into it. It's also a hard issue to write a good test case for, so verifying a fix without regressions is a bit tricky.

PR welcome obviously

@refractalize
Copy link

any appetite for just keeping the cursor visible in the first place? Using tmux, it's not obvious which pane is focussed without a cursor - or is that just me?

@Munter Munter added the type: bug a defect, confirmed by a maintainer label Jan 11, 2017
@Munter
Copy link
Member

Munter commented Jan 30, 2017

I think we're not listening to enough signals that might cause an exit, so we don't call cleanup properly. We could try using https://github.com/jtlapp/node-cleanup

@jayjanssen
Copy link

Same

@mscharley
Copy link

This is happening to me too. Personally, I'm in the same situation as refractalize. I'd be more than happy if there was a flag or something to disable this altogether.

@mscharley
Copy link

Yet more alternatives, an NPM script:

"scripts": {
  "fix-cursor": "node -e 'console.log(\"\\x1B[?25h\");'"
}

@glebec
Copy link

glebec commented Jun 11, 2019

Or an alias for your ~/.zshrc or bash profile, lol. Thanks @mcortesi & @rzane.

alias showc='echo "\x1B[?25h"' # show cursor after e.g. Mocha has hidden it

@juergba
Copy link
Member

juergba commented Sep 9, 2019

closed by #3980

@juergba juergba closed this as completed Sep 9, 2019
@jedwards1211
Copy link

jedwards1211 commented Feb 24, 2021

@juergba I'm still seeing this issue in Mocha 8.2.1, it never seems to have gone away
Actually, seems like it might be some subtle issue with spawning mocha with stdio: 'inherit'... 😕 or something else my own scripts are doing with chalk...

Another confusing thing that's happening to me is after I Ctrl-C, when I press the up arrow to go back to the last command, it prints ^[[A instead of showing the command. This even if I use the workaround shown above

Okay nevermind, the issue was whenever running via yarn 1 or my own spawn scripts that fail to pass SIGINT to the child process and wait for it to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

10 participants