patch 9.1.1757: The colorresp plugin causes additional redraws

Problem:  The colorresp plugin causes additional redraws
          (Linwei, after v9.1.1703)
Solution: Move the code back into the C core and get rid of the vim
          plugin (Foxe Chen)

fixes: #18251
closes: #18279

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Foxe Chen
2025-09-14 04:38:33 -04:00
committed by Christian Brabandt
parent c975d62473
commit c077f5e9d8
13 changed files with 251 additions and 170 deletions

View File

@ -1,4 +1,4 @@
*autocmd.txt* For Vim version 9.1. Last change: 2025 Sep 11
*autocmd.txt* For Vim version 9.1. Last change: 2025 Sep 14
VIM REFERENCE MANUAL by Bram Moolenaar
@ -1313,8 +1313,10 @@ TermResponseAll After the response to |t_RV|, |t_RC|, |t_RS|,
correspondingly, can be used. <amatch> will
be set to any of:
"ambiguouswidth" (|t_u7|),
"background" (|t_RB|),
"cursorblink" (|t_RC|),
"cursorshape" (|t_RS|),
"foreground" (|t_RF|),
"da1",
"osc",
"version" (|t_RV|)
@ -1322,15 +1324,6 @@ TermResponseAll After the response to |t_RV|, |t_RC|, |t_RS|,
executing another event, especially if file I/O,
a shell command or anything else that takes time
is involved.
Note: Traditionally, TermResponseAll was also
used for "foreground" and "background"
patterns. These are now handled as part of
the "osc" value. For backwards compatibility,
the $VIMRUNTIME/plugin/colorresp.vim plugin
will handle "osc" events and emit
TermResponseAll autocommand events when it
encounters "foreground" and "background"
values.
*TextChanged*
TextChanged After a change was made to the text in the
current buffer in Normal mode. That is after

View File

@ -1,4 +1,4 @@
*eval.txt* For Vim version 9.1. Last change: 2025 Aug 29
*eval.txt* For Vim version 9.1. Last change: 2025 Sep 14
VIM REFERENCE MANUAL by Bram Moolenaar
@ -2896,15 +2896,16 @@ v:termstyleresp The escape sequence returned by the terminal for the |t_RS|
*v:termrbgresp* *termrbgresp-variable*
v:termrbgresp The escape sequence returned by the terminal for the |t_RB|
termcap entry. This is used to find out what the terminal
background color is; see 'background'. This is set by the
$VIMRUNTIME/plugin/colorresp.vim plugin normally included with
Vim, but can be set manually if you know what you are doing.
Note that changing this will not do anything.
background color is; see 'background'. When this option is
set, the TermResponseAll autocommand event is fired, with
<amatch> set to "background".
*v:termrfgresp* *termrfgresp-variable*
v:termrfgresp The escape sequence returned by the terminal for the |t_RF|
termcap entry. This is used to find out what the terminal
foreground color is. Behaves the same as |v:termrbgresp|
foreground color is. When this option is set, the
TermResponseAll autocommand event is fired, with <amatch> set
to "foreground".
*v:termu7resp* *termu7resp-variable*
v:termu7resp The escape sequence returned by the terminal for the |t_u7|
@ -2923,9 +2924,7 @@ v:termda1 The escape sequence returned by a primary device attributes
v:termosc The escape sequence of the most recent OSC response received
from the terminal. When this variable is set, the
|TermResponseAll| autocommand event is fired, with <amatch>
set to "osc". Also used to set the |v:termrbgresp| and
|v:termrfgresp| via the $VIMRUNTIME/plugin/colorresp.vim
plugin
set to "osc".
*v:testing* *testing-variable*
v:testing Must be set before using `test_garbagecollect_now()`.

View File

@ -1,4 +1,4 @@
*version9.txt* For Vim version 9.1. Last change: 2025 Sep 13
*version9.txt* For Vim version 9.1. Last change: 2025 Sep 14
VIM REFERENCE MANUAL by Bram Moolenaar
@ -41759,9 +41759,6 @@ Others: ~
Command-line.
- |min()|/|max()| can handle all comparable data types.
- Vim triggers the |TermResponseAll| autocommand for any terminal OSC value.
- Vim includes the $VIMRUNTIME/plugins/colorresp.vim which parses the terminal
OSC response and can trigger a |TermResponseAll| with the "background" or
"foreground" value.
Platform specific ~
- MS-Winodws: Paths like "\Windows" and "/Windows" are now considered to be

View File

@ -3,7 +3,6 @@ The plugin directory is for standard Vim plugin scripts.
All files here ending in .vim will be sourced by Vim when it starts up.
Look in the file for hints on how it can be disabled without deleting it.
colorresp.vim used to detect terminal background and foreground colours
getscriptPlugin.vim get latest version of Vim scripts
gzip.vim edit compressed files
logiPat.vim logical operators on patterns

View File

@ -1,51 +0,0 @@
vim9script
# Vim plugin for setting the background and foreground colours depending on
# the terminal response.
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
# Last Change: 2025 Sep 05
if exists("g:loaded_colorresp")
finish
endif
g:loaded_colorresp = 1
augroup ColorResp
au!
au TermResponseAll osc {
var parts: list<string> = matchlist(v:termosc, '\(\d\+\);rgb:\(\w\+\)/\(\w\+\)/\(\w\+\)')
if len(parts) >= 5
var type: string = parts[1]
var rval: number = str2nr(parts[2][: 1], 16)
var gval: number = str2nr(parts[3][: 1], 16)
var bval: number = str2nr(parts[4][: 1], 16)
if type == '11'
# Detect light or dark background by parsing OSC 11 RGB background reply
# from terminal. Sum the RGB values roughly; if bright enough, set
# 'background' to 'light', otherwise set it to 'dark'.
var new_bg_val: string = (3 * char2nr('6') < char2nr(parts[2]) + char2nr(parts[3]) + char2nr(parts[4])) ? "light" : "dark"
v:termrbgresp = v:termosc
&background = new_bg_val
# For backwards compatibility
if exists('#TermResponseAll#background')
doautocmd <nomodeline> TermResponseAll background
endif
else
v:termrfgresp = v:termosc
# For backwards compatibility
if exists('#TermResponseAll#foreground')
doautocmd <nomodeline> TermResponseAll foreground
endif
endif
endif
}
au VimEnter * ++once {
call echoraw(&t_RB)
call echoraw(&t_RF)
}
augroup END
# vim: set sw=2 sts=2 :