Skip to content

Conversation

@hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Feb 25, 2024

Description

I couldn't identify the actual cause of cursor not getting back only on typecheck run, so I went with using logUpdate.done to explicitly restore the cursor. There could be some deeper bug specific to typecheck run, but I couldn't see anything suspicious.

additional notes

  • log-update is used only for reporters such as dot and default reporters on TTY, so the bug doesn't occur when using --reporter=tap for example.
  • log-update internally uses cli-cursor, which in turn uses restore-cursor. Since we haven't used logUpdate.done, probably we're relying on restore-cursor's automatic restoration, which somehow doesn't work on typecheck mode.

test

  • run pnpm -C examples/typecheck test:run
  • verify cursor is restored

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link

netlify bot commented Feb 25, 2024

Deploy Preview for fastidious-cascaron-4ded94 canceled.

Name Link
🔨 Latest commit 366a78b
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/65dac839d9f47f0008878e9d

@hi-ogawa hi-ogawa changed the title fix(vitest): ensure restore terminal cursor fix(vitest): ensure restoring terminal cursor on close Feb 25, 2024
@hi-ogawa hi-ogawa marked this pull request as ready for review February 25, 2024 05:22
Copy link
Member

@AriPerkkio AriPerkkio left a comment

Choose a reason for hiding this comment

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

we're relying on restore-cursor's automatic restoration, which somehow doesn't work on typecheck mode.

As this is such small fix I think it's ok as is. But it would be good to find why exactly restore-custor's exit-patch doesn't trigger in typecheck mode.

If typecheck run is now interrupted with CTRL+c, does the cursor restore correctly?

@hi-ogawa
Copy link
Contributor Author

If typecheck run is now interrupted with CTRL+c, does the cursor restore correctly?

I just tested now and surprisingly it restores correctly both before and after this fix.

I'd like to get to the bottom of it. I'm guessing something wrong with restore-cursor or signal-exit, but it would be still bizarre if typecheck + run would affect anything, so I might be looking at the wrong thing.

@sheremet-va sheremet-va merged commit 0bea224 into vitest-dev:main Mar 14, 2024
@hi-ogawa hi-ogawa deleted the fix-typecheck-run-restore-terminal-cursor branch March 16, 2024 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal cursor is not restored with --typecheck in run mode

3 participants