]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0440: MS-Windows: cursor flicker during update_screen() v9.2.0440
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Mon, 4 May 2026 19:58:27 +0000 (19:58 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 4 May 2026 19:58:27 +0000 (19:58 +0000)
Problem:  MS-Windows: cursor flicker during update_screen()
Solution: Hide the cursor during update_screen() to avoid Windows ConPTY
          flicker (Yasuhiro Matsumoto).

On terminals that do not honor synchronized output mode (e.g. Windows
ConPTY), update_screen() emits cell positioning and content as multiple
Win32 console writes through mch_write(), which the terminal renders as
separate frames.  This shows up as the cursor briefly jumping to column
1 of rows being redrawn, especially during async redraws around the
popup completion menu.

Disable the cursor with cursor_off() at the start of update_screen()
and restore it with cursor_on() at the end, but only when synchronized
output mode is not active.  When it is, the redraw is already atomic
from the terminal's view and hiding the cursor would only add visible
blink with no benefit.

closes: #20121

Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/drawscreen.c
src/proto/term.pro
src/term.c
src/version.c

index 702d686abaedfb118b9282a2ce75555c65a7e9cf..cecfcccb62db7a5daa17b5800b4bd0d23c1ab175 100644 (file)
@@ -160,6 +160,11 @@ update_screen(int type_arg)
     }
     updating_screen = TRUE;
 
+    // Hide the cursor while redrawing when sync output is not active, to
+    // avoid visible cursor flicker on terminals like Windows ConPTY.
+    int hid_cursor = !sync_output_active();
+    if (hid_cursor)
+       cursor_off();
     term_set_sync_output(TERM_SYNC_OUTPUT_ENABLE);
 
 #ifdef FEAT_PROP_POPUP
@@ -447,6 +452,8 @@ update_screen(int type_arg)
 #endif
 
     term_set_sync_output(TERM_SYNC_OUTPUT_DISABLE);
+    if (hid_cursor)
+       cursor_on();
 
     return OK;
 }
index 9653a35af3bce9fec1998e144614f303815e713a..3f099338be5fbbfb643f85f1b5e86fb672cdab28 100644 (file)
@@ -98,5 +98,6 @@ void cterm_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx);
 int term_replace_keycodes(char_u *ta_buf, int ta_len, int len_arg);
 void term_disable_dec(void);
 void term_set_win_resize(bool state);
+int sync_output_active(void);
 void term_set_sync_output(int flags);
 /* vim: set ft=c : */
index 07eb5974b7ebd8b948c6a28516ae8ba1147673c1..37f05ed0163472c1306c8a7ef56bbd92aef59f10 100644 (file)
@@ -8094,6 +8094,17 @@ term_set_win_resize(bool state)
 }
 #endif
 
+    int
+sync_output_active(void)
+{
+#ifdef FEAT_GUI
+    if (gui.in_use)
+       return TRUE;
+#endif
+    return p_tsy && (sync_output_setting == 1 || sync_output_setting == 2)
+       && *T_BSU != NUL && *T_ESU != NUL;
+}
+
 /*
  * Enable or disable synchronized output if possible. Specification can be found
  * here:
index 81809c9ea467eff68f3586430fe189106473be2a..34f3dd8508260653369fe18b46df2c314317f68f 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    440,
 /**/
     439,
 /**/