{"action":"created","issue":{"url":"https://api.github.com/repos/vim/vim/issues/1343","repository_url":"https://api.github.com/repos/vim/vim","labels_url":"https://api.github.com/repos/vim/vim/issues/1343/labels{/name}","comments_url":"https://api.github.com/repos/vim/vim/issues/1343/comments","events_url":"https://api.github.com/repos/vim/vim/issues/1343/events","html_url":"https://github.com/vim/vim/issues/1343","id":198069249,"number":1343,"title":"Incorrect highlighting with termguicolors, cursorline and spell","user":{"login":"puremourning","id":10584846,"avatar_url":"https://avatars.githubusercontent.com/u/10584846?v=3","gravatar_id":"","url":"https://api.github.com/users/puremourning","html_url":"https://github.com/puremourning","followers_url":"https://api.github.com/users/puremourning/followers","following_url":"https://api.github.com/users/puremourning/following{/other_user}","gists_url":"https://api.github.com/users/puremourning/gists{/gist_id}","starred_url":"https://api.github.com/users/puremourning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puremourning/subscriptions","organizations_url":"https://api.github.com/users/puremourning/orgs","repos_url":"https://api.github.com/users/puremourning/repos","events_url":"https://api.github.com/users/puremourning/events{/privacy}","received_events_url":"https://api.github.com/users/puremourning/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-29T21:12:10Z","updated_at":"2016-12-29T23:59:18Z","closed_at":null,"body":"## Issue\r\n\r\nWhen the `termguicolors`, `spell` and `cursorline` are set and the `Normal` highlight group sets a background colour, misspelled words are rendered incorrectly when they appear outside of another highlighting group and the cursor is on that line.\r\n\r\nSteps to reproduce\r\n\r\n* Create a file `vimrc_hl_test` with the following contents:\r\n\r\n```viml\r\nset termguicolors\r\nset cursorline\r\nsyntax clear\r\nhighlight clear\r\nhi! Normal cterm=NONE gui=NONE ctermfg=12 guifg=white ctermbg=8 guibg=black\r\nhi! SpellBad cterm=NONE,undercurl gui=NONE,undercurl ctermfg=NONE guifg=NONE ctermbg=NONE guibg=NONE guisp=#d33682\r\nsyntax enable\r\nsyntax on\r\nsyn spell toplevel\r\nset spell\r\n```\r\n\r\n* Edit a file with the following command: `vim -Nu vimrc_hl_test` and type `Slpelling error.<ESC>j`\r\n\r\n## Expected behaviour\r\n\r\nThe word `Slpelling` is rendered underlined with a foreground colour of 'white'\r\n\r\n## Actual behaviour\r\n\r\nThe word `Slpelling` is rendered underlined, but with a foreground colour of 'black'.\r\n\r\n## Follow-ups\r\n\r\n* Variations of `guifg` and `guibg` on the `Normal` group do not change the behaviour. It appears still rendered as black.\r\n* `set notermguicolors` - The text is rendered as expected (or at least the same colour as the other text)\r\n\r\n## Installed versions, environment etc.\r\n\r\nOS: macOS\r\nVim: master as of today (c4bfedabe057c05f09a455a5851089e177fa9c00)\r\nTrue color terminal: iterm2\r\n\r\n```\r\n:version\r\nVIM - Vi IMproved 8.0 (2016 Sep 12, compiled Dec 29 2016 20:42:18)\r\nMacOS X (unix) version\r\nIncluded patches: 1-134\r\nCompiled by ben@Bens-MacBook-Pro.local\r\nHuge version without GUI.  Features included (+) or not (-):\r\n+acl             +cindent         +cryptv          -ebcdic          +float           +job             +listcmds        +mouse_dec       +multi_byte      +persistent_undo +rightleft       +syntax          +textobjects     +visualextra     -xfontset\r\n+arabic          -clientserver    -cscope          +emacs_tags      +folding         +jumplist        +localmap        -mouse_gpm       +multi_lang      +postscript      +ruby/dyn        +tag_binary      +timers          +viminfo         -xim\r\n+autocmd         +clipboard       +cursorbind      +eval            -footer          +keymap          -lua             -mouse_jsbterm   -mzscheme        +printer         +scrollbind      +tag_old_static  +title           +vreplace        -xpm\r\n-balloon_eval    +cmdline_compl   +cursorshape     +ex_extra        +fork()          +lambda          +menu            +mouse_netterm   +netbeans_intg   +profile         +signs           -tag_any_white   -toolbar         +wildignore      -xsmp\r\n-browse          +cmdline_hist    +dialog_con      +extra_search    -gettext         +langmap         +mksession       +mouse_sgr       +num64           -python          +smartindent     -tcl             +user_commands   +wildmenu        -xterm_clipboard\r\n++builtin_terms  +cmdline_info    +diff            +farsi           -hangul_input    +libcall         +modify_fname    -mouse_sysmouse  +packages        +python3         +startuptime     +termguicolors   +vertsplit       +windows         -xterm_save\r\n+byte_offset     +comments        +digraphs        +file_in_path    +iconv           +linebreak       +mouse           +mouse_urxvt     +path_extra      +quickfix        +statusline      +terminfo        +virtualedit     +writebackup\r\n+channel         +conceal         -dnd             +find_in_path    +insert_expand   +lispindent      -mouseshape      +mouse_xterm     -perl            +reltime         -sun_workshop    +termresponse    +visual          -X11\r\n   system vimrc file: \"$VIM/vimrc\"\r\n     user vimrc file: \"$HOME/.vimrc\"\r\n 2nd user vimrc file: \"~/.vim/vimrc\"\r\n      user exrc file: \"$HOME/.exrc\"\r\n       defaults file: \"$VIMRUNTIME/defaults.vim\"\r\n  fall-back for $VIM: \"/Users/ben/Development/vim2-root/share/vim\"\r\nCompilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1\r\nLinking: gcc   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa     -L/usr/local/Cellar/python3/3.5.1/Frameworks/Python.fr\r\namework/Versions/3.5/lib/python3.5/config-3.5m -lpython3.5m -framework CoreFoundation\r\n```\r\n\r\nPlease don't hesitate to ask if further information is required. I'm afraid I don't currently have a true colour xterm to test in for a more canonical environment.\r\n"},"comment":{"url":"https://api.github.com/repos/vim/vim/issues/comments/269712502","html_url":"https://github.com/vim/vim/issues/1343#issuecomment-269712502","issue_url":"https://api.github.com/repos/vim/vim/issues/1343","id":269712502,"user":{"login":"puremourning","id":10584846,"avatar_url":"https://avatars.githubusercontent.com/u/10584846?v=3","gravatar_id":"","url":"https://api.github.com/users/puremourning","html_url":"https://github.com/puremourning","followers_url":"https://api.github.com/users/puremourning/followers","following_url":"https://api.github.com/users/puremourning/following{/other_user}","gists_url":"https://api.github.com/users/puremourning/gists{/gist_id}","starred_url":"https://api.github.com/users/puremourning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puremourning/subscriptions","organizations_url":"https://api.github.com/users/puremourning/orgs","repos_url":"https://api.github.com/users/puremourning/repos","events_url":"https://api.github.com/users/puremourning/events{/privacy}","received_events_url":"https://api.github.com/users/puremourning/received_events","type":"User","site_admin":false},"created_at":"2016-12-29T23:59:18Z","updated_at":"2016-12-29T23:59:18Z","body":"OK I have a fix for this. \r\n\r\n```diff\r\nBens-MacBook-Pro:vim2 ben$ git diff\r\ndiff --git a/src/syntax.c b/src/syntax.c\r\nindex 75ede361c..ef0e45791 100644\r\n--- a/src/syntax.c\r\n+++ b/src/syntax.c\r\n@@ -8765,6 +8765,8 @@ hl_combine_attr(int char_attr, int prim_attr)\r\n        else\r\n        {\r\n            vim_memset(&new_en, 0, sizeof(new_en));\r\n+           new_en.ae_u.cterm.bg_rgb = INVALCOLOR;\r\n+           new_en.ae_u.cterm.fg_rgb = INVALCOLOR;\r\n            if (char_attr <= HL_ALL)\r\n                new_en.ae_attr = char_attr;\r\n        }\r\n```\r\n\r\nPR incoming."}}
{"actor":{"display_login":"puremourning"}}