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

ux.action.spinner overwrites most recent terminal output when updating spinner #799

Closed
mdonnalley opened this issue Sep 29, 2023 · 1 comment · Fixed by #832
Closed

ux.action.spinner overwrites most recent terminal output when updating spinner #799

mdonnalley opened this issue Sep 29, 2023 · 1 comment · Fixed by #832
Labels
bug Something isn't working

Comments

@mdonnalley
Copy link
Contributor

Describe the bug

The last line outputted to the terminal is overwritten when the spinner updates.

I've tracked it down to this line of code, https://github.com/oclif/core/blob/2.15.0/src/cli-ux/action/spinner.ts#L78, which uses ansi-escapes to move the cursor up and then erase everything underneath it. The underlying assumption is that it's moving the cursor to the beginning of the existing spinner, but that assumption fails once additional lines have been made to the terminal.

One potential solution is to use ansiEscapes.cursorSavePosition to capture the position of the cursor immediately after rendering the spinner and then use ansiEscapes.cursorRestorePosition to restore that position just before re-rendering it. I tested this and it did work until the spinner completed, at which point it cleared the additional logs. Maybe there's something to go off there.

To Reproduce

console.log('hello world 1') // this stays on the terminal
ux.action.start('starting spinner')
console.log('hello world 2')  // this stays on the terminal
console.log('hello world 3') // this gets overwritten once spinner updates
await ux.wait(2500)
ux.action.status = 'still going'
await ux.wait(2500)
ux.action.stop()
hello world 1
starting spinner...
hello world 2
starting spinner... done
@mdonnalley mdonnalley added the bug Something isn't working label Sep 29, 2023
@git2gus
Copy link

git2gus bot commented Sep 29, 2023

This issue has been linked to a new work item: W-14208351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant