-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Describe the bug
Vim currently sets the t_AU and t_8u termcap extensions (set underline color indexed and RGB, respectively) as follows:
let &t_AU = "\e[58;5;%dm"let &t_8u = "\e[58;2;%lu;%lu;%lum"
These are originally kitty extensions, but have since been added to more terminals. (hterm, iTerm2, mintty, and VTE are the ones I know of.)
Like the 38 and 48 SGR codes to set RGB foreground and background colors, the SGR 58 code has the same choice of semicolon or colon as subparameter delimiter. However, unlike 38 and 48, there's a lot fewer legacy terminals using the semicolon delimiter. As such, it seems that at least mintty only implemented the colon delimeter, which offers better compatibility with older SGR parsers.
To Reproduce
Detailed steps to reproduce the behavior:
For indexed:
- Run
vim --cleanin mintty. - Execute
hi clear SpellBad. - Execute
hi SpellBad cterm=underline ctermul=1. - Execute
set spell. - Type a misspelt word.
- Observe that the misspelt word is now blinking and the underline color is not changed. It appears mintty has parsed this as SGR 58, SGR 5 (blink).
For RGB color:
- Run
vim --cleanin mintty. - Execute
hi clear SpellBad. - Execute
hi SpellBad cterm=underline guisp=#00ff00. - Execute
set termguicolors. - Execute
set spell. - Type a misspelt word.
- Observe that the misspelt word is now not underlined at all. It appears mintty has parsed this as SGR 58, SGR 2 (dimmed).
Expected behavior
The text in the first case should have a red underline, and in the second case should have a green underline. The text should not blink or be dimmed.
Vim uses semicolon as a subparameter delimiter for SGR 38 and 48, and that's probably needed for compatibility; however, for the newer and much less widespread SGR 58, it looks like the colon delimiter actually has better compatability. It's also more likely be be ignored (instead of incorrectly processed as SGR 2 or SGR 5) on a terminal that doesn't support colored underlines at all. So I suggest the builtin xterm termcap be changed as follows:
let &t_AU = "\e[58:5:%dm"let &t_8u = "\e[58:2::%lu:%lu:%lum"
(Note the double colon in t_8u; this is indeed part of the syntax.)
I've tested these colon-delimited sequences in hterm, kitty, mintty, and VTE (Sakura) and they all work properly. I can't test iTerm2 since I don't have a Mac, but maybe @gnachman can help verify that?
Environment (please complete the following information):
$ vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jun 1 2020 06:42:35)
Included patches: 1-869
Compiled by <https://www.msys2.org/>
Huge version without GUI. Features included (+) or not (-):
+acl -farsi +mouse_sgr +tag_binary
+arabic +file_in_path -mouse_sysmouse -tag_old_static
+autocmd +find_in_path +mouse_urxvt -tag_any_white
+autochdir +float +mouse_xterm -tcl
-autoservername +folding +multi_byte +termguicolors
-balloon_eval -footer +multi_lang +terminal
+balloon_eval_term +fork() -mzscheme +terminfo
-browse +gettext +netbeans_intg +termresponse
++builtin_terms -hangul_input +num64 +textobjects
+byte_offset +iconv +packages +textprop
+channel +insert_expand +path_extra +timers
+cindent +ipv6 +perl/dyn +title
-clientserver +job +persistent_undo -toolbar
+clipboard +jumplist +popupwin +user_commands
+cmdline_compl +keymap +postscript +vartabs
+cmdline_hist +lambda +printer +vertsplit
+cmdline_info +langmap +profile +virtualedit
+comments +libcall +python/dyn +visual
+conceal +linebreak +python3/dyn +visualextra
+cryptv +lispindent +quickfix +viminfo
+cscope +listcmds +reltime +vreplace
+cursorbind +localmap +rightleft +wildignore
+cursorshape -lua +ruby/dyn +wildmenu
+dialog_con +menu +scrollbind +windows
+diff +mksession +signs +writebackup
+digraphs +modify_fname +smartindent -X11
-dnd +mouse -sound -xfontset
-ebcdic -mouseshape +spell -xim
+emacs_tags +mouse_dec +startuptime -xpm
+eval -mouse_gpm +statusline -xsmp
+ex_extra -mouse_jsbterm -sun_workshop -xterm_clipboard
+extra_search +mouse_netterm +syntax -xterm_save
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim82"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -I/usr/include/ncursesw -march=x86-64 -mtune=generic -O2 -pipe -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -pipe -fstack-protector-strong -pipe -Wl,--as-needed -o vim.exe -lm -lelf -lncursesw -liconv -lacl -lintl -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -ldl -lcrypt
$ uname -a
MINGW64_NT-10.0-19041 holden 3.1.6-340.x86_64 2020-07-17 05:52 UTC x86_64 Msys
$ mintty --version
mintty 3.2.0 (x86_64-pc-msys)
© 2013/2020 Andy Koppe / Thomas Wolff
License GPLv3+: GNU GPL version 3 or later
There is no warranty, to the extent permitted by law.