Reset terminal cursor style after each prompt #73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fix for #72 and #51. The solution here is to print
VTE_CURSOR_STYLE_TERMINAL_DEFAULT
, whose value is"\033[0 q"
, tostdout
after each prompt. When entering a new prompt line, this means that a reset sequence is sent, shortly followed by anIBEAM
sequence. I had concerns that this would cause unpleasant flashing, but it seems to be fast enough that a block isn't rendered for quick commands. It works well in my testing withxterm
,termite
,alacritty
, and the embedded terminal in vs-code (xtermjs
I think?).This does have an odd side-effect that the cursor returns to the default style while a long command is running, for example
sleep(5)
.In the course of testing this, I discovered that the vs-code terminal does not properly handle the control sequence for resetting the cursor to the default style (
\033[0 q
). Instead, it sets it to a blinking block cursor. There is a well-detailed issue documenting this: xtermjs/xterm.js#3293This might justify a new issue for this package. It's certainly annoying—we may be able to have a hacky mitigation detecting if any vs-code related libraries, and setting the cursor to block. Not a great solution though.