Bug 496534 - Color of Underline/Undercurl cannot be set within vim when using Konsole
Summary: Color of Underline/Undercurl cannot be set within vim when using Konsole
Status: RESOLVED DOWNSTREAM
Alias: None
Product: konsole
Classification: Applications
Component: general (other bugs)
Version First Reported In: 24.08.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-21 10:19 UTC by terrycchau@gmail.com
Modified: 2024-11-26 19:16 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Example of what the undercurl color looks like in Konsole (189.87 KB, image/png)
2024-11-21 10:19 UTC, terrycchau@gmail.com
Details
Example of what the undercurl color looks like in xfce-terminal (38.77 KB, image/png)
2024-11-21 10:21 UTC, terrycchau@gmail.com
Details
Output showing that Konsole is capable of undercurl colors (61.00 KB, image/png)
2024-11-21 10:21 UTC, terrycchau@gmail.com
Details

Note You need to log in before you can comment on or make changes to this bug.
Description terrycchau@gmail.com 2024-11-21 10:19:56 UTC
Created attachment 176000 [details]
Example of what the undercurl color looks like in Konsole

SUMMARY
The color of underline/undercurl as set in vim does not display in Konsole

STEPS TO REPRODUCE
1. In a .vimrc file in home directory (cd ~), add the following settings:
```
setlocal spell
try | lang en_US | catch | endtry
set spelllang=en_us
let &t_Cs = "\e[4:3m"
let &t_Ce = "\e[4:0m"
hi SpellBad term=underline cterm=underline gui=underline
```
then save the file.
2. Open vim, and then type a misspelled word.

OBSERVED RESULT
We see a red undercurl in other terminals such as: iterm2 and xfce4-terminal:1.1.3, but not in Konsole. The color of the undercurl remains the same color as the text.

EXPECTED RESULT
The undercurl color should red. 

SOFTWARE/OS VERSIONS
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 6.2.0
KDE Plasma Version: 6.2.0
KDE Frameworks Version: 6.7.0
Qt Version: 6.8.0

ADDITIONAL INFORMATION
Konsole clearly could support color undercurls as `echo -e "\e[4:3m\e[58:2::215:58:103mThis text has an undercurl with color\e[4:0m"` works in Konsole.  I have no idea why setting color undercurl in vim does not work.  This may be a vim specific issue, but it seems that my vim settings above work in other terminals, just not in Konsole, and I cannot figure out why.  If it helps, highlighting in vim is defined in https://github.com/vim/vim/blob/master/src/highlight.c.
Comment 1 terrycchau@gmail.com 2024-11-21 10:21:22 UTC
Created attachment 176001 [details]
Example of what the undercurl color looks like in xfce-terminal
Comment 2 terrycchau@gmail.com 2024-11-21 10:21:52 UTC
Created attachment 176002 [details]
Output showing that Konsole is capable of undercurl colors
Comment 3 Matan Ziv-Av 2024-11-22 10:54:21 UTC
(In reply to terrycchau@gmail.com from comment #2)
> Created attachment 176002 [details]
> Output showing that Konsole is capable of undercurl colors

What if you add the color sequence to t_Cs?

Since colored underlines do work, my first guess would be that vim sends different escape sequences. Is $TERM the same in both cases?

Can you run vim using `script` to see what escape sequences are actually sent?
Comment 4 terrycchau@gmail.com 2024-11-22 11:36:25 UTC
I should clarify that the .vimrc used contains:

```
set termguicolors
setlocal spell
try | lang en_US | catch | endtry
set spelllang=en_us
let &t_Cs = "\e[4:3m"
let &t_Ce = "\e[4:0m"
hi SpellBad term=undercurl cterm=undercurl gui=undercurl guifg=NONE ctermfg=NONE guisp=#d73a49 ctermbg=None
```
Comment 5 terrycchau@gmail.com 2024-11-22 11:51:24 UTC
(In reply to Matan Ziv-Av from comment #3)
> (In reply to terrycchau@gmail.com from comment #2)
> > Created attachment 176002 [details]
> > Output showing that Konsole is capable of undercurl colors
> 
> What if you add the color sequence to t_Cs?
> 
Setting let &t_Cs = "\e[4:3m\e[58:2::215:58:103m" would change the underline color to red.

> Since colored underlines do work, my first guess would be that vim sends
> different escape sequences. Is $TERM the same in both cases?
> 
$TERM for both xfce-terminal and konsole is `xterm-256color`.

> Can you run vim using `script` to see what escape sequences are actually
> sent?

If by script you mean Ex mode, I could enter that by pressing `Q` in the normal mode in vim, but I am not sure how to actually find the actual escape sequence.  Let me know if you have suggestions for commands to run.
Comment 6 terrycchau@gmail.com 2024-11-22 13:56:19 UTC
Good news. I figured out the issue.  Somehow &t_8u is being automatically set for vim in other terminals but not in konsole.  This is something that needs to be set in vims end.

Adding the following resolves issues.

```
let &t_8u = "\e[58;2;%lu;%lu;%lum"
```

&t_8u is set in https://github.com/vim/vim/blob/master/src/term.c I think.  Don't have the time to figure it all out atm.
Comment 7 John Kizer 2024-11-26 19:16:18 UTC
Nice catch! Indeed, looks like according to the comments the belief is/was that Konsole doesn't support something that it apparently does:

https://github.com/vim/vim/blob/7e501f4d9986866382888e67d8f11faf5767c8f4/src/term.c#L5176