@@ -4547,22 +4547,6 @@ check_termcode(
45474547 {
45484548 int need_flush = FALSE;
45494549
4550- /* Only set 'ttymouse' automatically if it was not set
4551- * by the user already. */
4552- if (!option_was_set ((char_u * )"ttym" ))
4553- {
4554- # ifdef TTYM_SGR
4555- if (version >= 277 )
4556- set_option_value ((char_u * )"ttym" , 0L ,
4557- (char_u * )"sgr" , 0 );
4558- else
4559- # endif
4560- /* if xterm version >= 95 use mouse dragging */
4561- if (version >= 95 )
4562- set_option_value ((char_u * )"ttym" , 0L ,
4563- (char_u * )"xterm2" , 0 );
4564- }
4565-
45664550 /* if xterm version >= 141 try to get termcap codes */
45674551 if (version >= 141 )
45684552 {
@@ -4581,6 +4565,28 @@ check_termcode(
45814565 * 256, libvterm supports even more. */
45824566 if (mch_getenv ((char_u * )"COLORS" ) == NULL )
45834567 may_adjust_color_count (256 );
4568+ # ifdef FEAT_MOUSE_SGR
4569+ /* Libvterm can handle SGR mouse reporting. */
4570+ if (!option_was_set ((char_u * )"ttym" ))
4571+ set_option_value ((char_u * )"ttym" , 0L ,
4572+ (char_u * )"sgr" , 0 );
4573+ # endif
4574+ }
4575+
4576+ /* Only set 'ttymouse' automatically if it was not set
4577+ * by the user already. */
4578+ if (!option_was_set ((char_u * )"ttym" ))
4579+ {
4580+ # ifdef FEAT_MOUSE_SGR
4581+ if (version >= 277 )
4582+ set_option_value ((char_u * )"ttym" , 0L ,
4583+ (char_u * )"sgr" , 0 );
4584+ else
4585+ # endif
4586+ /* if xterm version >= 95 use mouse dragging */
4587+ if (version >= 95 )
4588+ set_option_value ((char_u * )"ttym" , 0L ,
4589+ (char_u * )"xterm2" , 0 );
45844590 }
45854591
45864592 /* Detect terminals that set $TERM to something like
0 commit comments