[vim/vim] `r`eplace mode cursor shape bug (Windows Terminal) (#6576)

37 views
Skip to first unread message

gustaphe

unread,
Jul 30, 2020, 8:34:27 AM7/30/20
to vim/vim, Subscribed

Describe the bug
When &t_SR or &t_SI is set, insert and Replace mode work as expected, but in replace, the cursor jumps visually five steps to the right (seems to correspond to the length of the string variable) while the operation is pending. After replacement the cursor returns correctly, but if the character was changed, the new character is visually followed by the string in &t_EI (without the ^[), and the cursor does not change back from the underline mode. This can be reset by triggering a redraw (^L).

I can't tell what changes in how r sends ansi escape codes compared to R, but something causes the two codes to interfere.

To Reproduce

  1. In Windows Terminal, run vim --clean
  2. :let &t_SR="\e[7 q", :let &t_EI="\e[2 q"
  3. Write abcdefg
  4. Place cursor on a
  5. Press r, first bug: cursor moves to f
  6. Press b, second bug: text becomes b[2 qfg, cursor is still the replace shape
  7. Press <C-L>, text is bbcdefg

Expected behavior
The cursor should stay in the same place, the text should immediately become bbcdefg and the cursor should reset.

Screenshots
image
image
image

Environment (please complete the following information):

  • VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Dec 12 2019 13:19:27)
  • OS: Windows 10, 18363
  • Terminal: Windows Terminal


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

gustaphe

unread,
Aug 7, 2020, 12:47:23 PM8/7/20
to vim/vim, Subscribed

Update, using
let &t_SR="\<CSI>7\ q" and let &t_EI="\<CSI>2\ q" fixes the second bug, but the cursor still jumps (but to e now, I guess because &t_SR is one character shorter)

rmford91

unread,
Aug 8, 2022, 12:49:42 PM8/8/22
to vim/vim, Subscribed

@gustaphe Were you able to find a fix for the cursor jumping forward? I'm currently dealing with this same issue and haven't been able to find a solution


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6576/1208364962@github.com>

gustaphe

unread,
Aug 8, 2022, 12:54:54 PM8/8/22
to vim/vim, Subscribed

No. In the WT convo linked above I've updated the description a little (new and interesting bugs ...), and there's a comment describing using C to solve it. One day I'll look into that, but I keep forgetting to.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6576/1208369987@github.com>

K.Takata

unread,
Aug 8, 2022, 11:34:14 PM8/8/22
to vim/vim, Subscribed

(Implementation detail)

Win32 version of Vim uses its own terminal codes:
https://github.com/vim/vim/blob/ad6d9cc679259936b7c8453f17c0ec9d7ab7dcd0/src/term.c#L561-L570
and they are translated into actual escape sequences (or into Win32 console API calls):
https://github.com/vim/vim/blob/ad6d9cc679259936b7c8453f17c0ec9d7ab7dcd0/src/os_win32.c#L6454-L6462

Currently, this doesn't support t_SR, t_SI and so on. Maybe we need to pass through these kind of esc sequences.

BTW, I found that this function missing implementation for Windows Terminal:
https://github.com/vim/vim/blob/ad6d9cc679259936b7c8453f17c0ec9d7ab7dcd0/src/os_win32.c#L1523-L1528


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6576/1208871454@github.com>

gustaphe

unread,
Aug 9, 2022, 4:45:30 AM8/9/22
to vim/vim, Subscribed

Okay, now there's a plugin at gustaphe/winterm.vim


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6576/1209092690@github.com>

K.Takata

unread,
Sep 1, 2022, 2:23:45 AM9/1/22
to vim/vim, Subscribed

I'm now preparing a patch for this issue:
https://osdn.net/users/k_takata/pf/vim-ktakata-mq/scm/blobs/312c07eac6ba0528dde08cbd240fc7ea10fe3e44/win32-set-cursor-style.patch

The following .vimrc works after applying this patch.

" Change cursor shape
if &term =~ 'xterm' || &term == 'win32'
  " Use DECSCUSR escape sequences
  let &t_SI = "\e[5 q"    " blink bar
  let &t_SR = "\e[3 q"    " blink underline
  let &t_EI = "\e[1 q"    " blink block
  let &t_ti .= "\e[1 q"   " blink block
  let &t_te .= "\e[0 q"   " default (normally blink block)
endif


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/6576/1233799130@github.com>

Bram Moolenaar

unread,
Sep 1, 2022, 8:21:04 AM9/1/22
to vim/vim, Subscribed

Closed #6576 as completed via df5320c.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/6576/issue_event/7304726655@github.com>

Reply all
Reply to author
Forward
0 new messages