fix(vitest): ensure restoring terminal cursor on close
Description
- Closes https://github.com/vitest-dev/vitest/issues/5247
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-updateis used only for reporters such asdotanddefaultreporters on TTY, so the bug doesn't occur when using--reporter=tapfor example.log-updateinternally uses cli-cursor, which in turn uses restore-cursor. Since we haven't usedlogUpdate.done, probably we're relying onrestore-cursor's automatic restoration, which somehow doesn't work ontypecheckmode.
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:
- [x] 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.yamlunless 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 docscommand.
Changesets
- [x] 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:, orchore:.
Deploy Preview for fastidious-cascaron-4ded94 canceled.
| Name | Link |
|---|---|
| Latest commit | 366a78b39aeb0173eee47c95187527fa5130b175 |
| Latest deploy log | https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/65dac839d9f47f0008878e9d |
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.