vscode: Cursor does not blink in integrated terminal for webgl

Issue Type: Bug

Does this issue occur when all extensions are disabled?: Yes

Steps to reproduce:

  1. Add "terminal.integrated.cursorBlinking": true to settings.json file.
  2. Start VS Code with code --disable-extensions.
  3. Launch integrated terminal (e.g. with CMD-J on Mac).
  4. Observe that the cursor in the integrated terminal is not blinking, even when the focus is on the integrated terminal.

VS Code version: Code 1.59.1 (3866c3553be8b268c8a7f8c0482c0c0177aa8bfa, 2021-08-19T11:53:52.479Z) OS version: Darwin x64 18.7.0 Restricted Mode: No

System Info
Item Value
CPUs Intel® Core™ i7-9750H CPU @ 2.60GHz (12 x 2600)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 1, 1, 1
Memory (System) 16.00GB (8.02GB free)
Process Argv –disable-extensions --crash-reporter-id fe789409-e4d3-492d-b5c7-952d2b0ca735
Screen Reader no
VM 0%
Extensions disabled
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
pythonvspyt602:30300191
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt639:30300192
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
pythonvsuse255:30340121
vscod805cf:30301675
pythonvspyt200:30340761
vscextlang:30333561
binariesv615:30325510
pythonvssor306:30344512
bridge0708:30335490
vstre464:30350172
bridge0723:30353136
vsdyn420:30354109

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 18 (11 by maintainers)

Commits related to this issue

Most upvoted comments

The problem is that when setting terminal.integrated.cursorBlinking to true, it ONLY works with the currently opened terminal sessions.

If the terminal pane is closed, by clicking “Close Panel” (X) button, then when reopening the same terminal sessions. the cursor still blinks.

image

But if I quit the terminal by terminating the shell, either via exit or <kbd> ctrl + d </kbd>, then the new integrated terminal sessions do not have blinking cursors even though the setting is still on.


As noted in the other issue:

Steps

  1. open the fresh insider build
  2. open the integrated terminal, and focus it
  3. notice the terminal cursor doesn’t blink, this is expected since “terminal.integrated.cursorBlinking” defaults to false
  4. open settings, turn on terminal cursor blinking
  5. now focus the integrated terminal again, see that the terminal cursor starts blinking
  6. run the exit command, or press <kbd>ctrl + d</kbd>, RATHER THAN closing the terminal panel
  7. again, open a new integrated terminal, here the terminal cursor DOES NOT blink, even though the setting is still on.

And the problem is with the last step above, apparently things are different regarding the terminal is whether a new one or not.

I just tested this with the latest Insider build and the problem still exists:

Version: 1.61.0-insider (Universal) Commit: 214ac689ca9874a8a4be386f73d5cb60e15af25e Date: 2021-09-28T05:14:06.244Z Electron: 13.4.0 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin x64 20.6.0

If you are on Mac or Linux you can check the color of the minimize maximise and close buttons. In which window it is colored that window is active. 🤷‍♂️

Dudes @CameronBieganek and @flaviocamilo you both can use the terminal, it has no issues. There is nothing wrong with the terminal if the cursor isn’t blinking.

@TarunavBA On the contrary, this affects the usability of the terminal. Here’s why:

The purpose of a blinking cursor is to visually indicate which pane/window within VS Code is currently active. Without a blinking cursor in the terminal, it is much harder to tell if the terminal is currently the active pane. The result is that I sometimes think I’m in the terminal and start typing a terminal command, but that text is instead inserted into a source file in the source editor, because it turns out that the source editor was the active pane rather than the integrated terminal. This is pretty annoying and a time waster.

Not to mention, there is a setting for a blinking terminal cursor, "terminal.integrated.cursorBlinking", and it doesn’t work. That is a bug.

Looking at the recent changes in xterm, it appears the CursorBlinkStateManager is only constructed within onOptionsChanged:

  public onOptionsChanged(): void {
    if (this._optionsService.options.cursorBlink) {
      if (!this._cursorBlinkStateManager) {
        this._cursorBlinkStateManager = new CursorBlinkStateManager(this._coreBrowserService.isFocused, () => {
          this._render(true);
        });
      }

See https://github.com/xtermjs/xterm.js/blob/8c94980315076e9c833b27fc3f8aff2bd7c32f67/src/browser/renderer/CursorRenderLayer.ts#L105-L111

This kinda reflects the symptom that it only works with existing terminal sessions when cursor blinking option is being turned on. And stops working in new terminal sessions after the current ones are terminated, thanks to the fact that the _cursorBlinkStateManager is now disposed properly.

I guess then we need to also properly instantiate the CursorBlinkStateManager, like in onFocus:

  public onFocus(terminal: Terminal): void {
    if (this._cursorBlinkStateManager) {
      this._cursorBlinkStateManager.resume(terminal);
    } else { 
      /////////////// <<<<<<<<------------ instantiate _cursorBlinkStateManager here
      this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.active.cursorY, end: terminal.buffer.active.cursorY });

Or maybe CursorBlinkStateManager is meant to be a singleton bound to the lifecycle of the current vscode instance, and it shouldn’t be disposed at all?

I can’t repro either, but looking at the code I’m guessing the issue is caused because we don’t init the cursor settings in the terminal ctor:

https://github.com/microsoft/vscode/blob/c2955308e54a3d4cff62ac0956cb32f5048eb171/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts#L573-L596

Perhaps a config update events is firing after that on some setups which causes the cursor settings to apply.

This is an issue for me as well, and has been for a while. I have tested this on Mac and Linux (Mint 18.x and Zorin 16) with both code-insiders and the stable version. I have also tried turning all extensions off, but the problem persists. I have not

For me, the cursor does blink the first time opening vscode and the integrated terminal. Then, if I kill the terminal and create a new, it stops blinking.

The only way to make it temporarily start again is to either reload the window, or change any of the settings that changes how the terminal-cursor renders (terminal.integrated.cursorWidth, terminal.integrated.cursorStyle, terminal.integrated.cursorBlinking, etc.).

Here is a gif I just made to show. Untitled (4)

while we work to fix this, you can set terminal.integrated.gpuAcceleration to off or canvas - it’s working properly for those renderers.

@ryenus thanks for the investigation 👍

This is most likely a regression in vscode 1.59.1, meanwhile in vscode 1.58.2 the cursor blinking just works, and the xterm versions are “4.15.0-beta.3” and “4.13.0” respectively.

I tried the xterm 4.13.0 with the latest vscode main branch and the cursor blinks fine too.

At some point during the day I end up typing terminal commands into source code because of this. I’m a command line guy and I live in vscode so it’s causing a lot of pain here.

This also happens on Linux.

Maybe something related to the updated version of Xterm.js, which resolved #106981?