Mocha: Cursor dissapears after CTRL-C in mocha --watch

Created on 21 Dec 2016  路  9Comments  路  Source: mochajs/mocha

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();
  });
confirmed-bug

Most helpful comment

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?

All 9 comments

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

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

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

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?

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

Same

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.

Yet more alternatives, an NPM script:

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

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

closed by #3980

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Swivelgames picture Swivelgames  路  3Comments

3p3r picture 3p3r  路  3Comments

eschwartz picture eschwartz  路  3Comments

adamhooper picture adamhooper  路  3Comments

wzup picture wzup  路  3Comments