terminal: No cursor after exiting vim

Windows Terminal version (or Windows build number)

1.8.1521.0

Other Software

vim 7.4.576 (via SSH inside WSL)

        linux-vdso.so.1 (0x00007ffffd7f6000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f151d9c1000)
        libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f151d797000)
        libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f151d572000)
        libacl.so.1 => /lib/x86_64-linux-gnu/libacl.so.1 (0x00007f151d369000)
        libgpm.so.2 => /usr/lib/x86_64-linux-gnu/libgpm.so.2 (0x00007f151d163000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f151cf5f000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f151cbb4000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f151c946000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f151e0ef000)
        libattr.so.1 => /lib/x86_64-linux-gnu/libattr.so.1 (0x00007f151c741000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f151c524000)

Steps to reproduce

A few times start vim, switch the window and wait…

Expected Behavior

Everytime a flashing cursor after switching back.

Actual Behavior

Sometimes the cursor disappears, reset(1) helps.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

This is not exclusive to vim. Running top also causes the cursor to stop blinking.

As much as I agree the issue is with the apps themselves and Microsoft Terminal is doing the right thing here, maybe an option to ignore that request like it was traditionally done would be nice.

Terminal 1.12.10983.0 Ubuntu 22.04.4 (Jammy) Vim 8.2 procps-ng 3.3.17

For completeness (see #12372), I just discovered that MinTTY people has enabled by default the MinTTY option

SuppressDEC=12

See https://github.com/mintty/mintty/wiki/Tips#blinking-cursor-reset

In the case of vim, you can get it to reset the cursor on exit by tweaking the t_ti and t_te options. For example, I have these lines in my .vimrc file (note that ^[ is <kbd>Ctrl</kbd>+<kbd>[</kbd>).

set t_ti=^[[1049h
set t_te=^[[1049l^[[0\ q

On startup that switches to the alt buffer (CSI 1049h), and on exit it switches back to the main buffer (CSI 1049l), and resets the cursor (CSI 0 q). I don’t know if this is the best solution, but it works for me.

It’s worth noting that I’m seeing a similar issue with tig.

In the case of tig, the current behaviour is also “by design”. They’re essentially asking for the cursor blinking to be disabled on shutdown. They’re executing the cursor_normal terminfo entry, which for xterm-256color is \E[?12l\E[?25h (i.e. cursor blink off and visibility on). You’ll get the same result in XTerm. I don’t know if there’s a way to work around that, but you should probably raise the issue with tig.

Well, at least Xterm.js supports DECSCUSR

Yeah but vim is using private mode 12 to disable the cursor blinking, and Xterm.js doesn’t appear to support that. https://github.com/xtermjs/xterm.js/blob/e746cd55ddafb9120e3f00cf00e4360d14a531a4/src/common/InputHandler.ts#L1948-L1950

Technically I suspect it’s just using the cursor_normal terminfo entry, the same as tig, and as I pointed out above, that disables mode 12 and enables mode 25 for xterm-256color.

Well if you want to fix the root cause then you’ll probably need to take this up with vim. They’re the ones that are turning the blinking off. I don’t think it’s anything specific to Windows Terminal, because I’ve seen the exact same behaviour in several other terminals, including XTerm , Rxvt, and Alacritty. The only terminals I’ve seen that weren’t affected were those that simply don’t support the cursor blinking mode, so they’re only “working” accidentally.

It’s worth noting that I’m seeing a similar issue with tig. For both vim and tig, if the cursor stops blinking once I exit the application.