vim-css-color icon indicating copy to clipboard operation
vim-css-color copied to clipboard

Error with files with no highlightable targets in Vim9

Open Aryailia opened this issue 3 years ago • 0 comments

When opening HTML or markdown files without anything that vim-css-color would normally color, I get the following error at startup:

Error detected while processing BufNewFile Autocommands for "*.md"..FileType Autocommands for
 "*"..Syntax Autocommands for "*"..function <SNR>4_SynSet[25]..script /usr/share/vim/vim90/sy
ntax/markdown.vim[15]../home/user/.config/vim/package/vim-css-color/after/syntax/html.vim[2]..
function css_color#init[10]..css_color#enable[15]..CursorMoved Autocommands for "<buffer=1>".
.function <SNR>42_parse_screen[5]..<SNR>42_create_syn_match[20]..BufNewFile Autocommands for
"*.md"..FileType Autocommands for "*"..Syntax Autocommands for "*"..function <SNR>4_SynSet[25
]..script /usr/share/vim/vim90/syntax/markdown.vim[15]../home/user/.config/vim/package/vim-css
-color/after/syntax/html.vim[2]..function css_color#init[10]..css_color#enable[15]..CursorMov
ed Autocommands for "<buffer=1>"..function <SNR>42_parse_screen[5]..<SNR>42_create_syn_match:

line   20:
E605: Exception not caught: css_color: create_syn_match invoked on bad match data

This doesn't seem to affect anything other than displaying an error message at vim startup. This happens on files with content and with new files, the problem seeming to be the lack of a highlightable color. This error also occurs with a fresh .vimrc, VimPlug, set nocompatible, filetype plugin indent on. This seems to be an issue that has only popped up as of vim9 (vim-9.0.0135). Running the my full vim setup in a docker container that has vim8 seems to not run into this issue.

As soon as I save something like <div color="#AA0000"> and reopen the file, vim no longer displays the error.

I narrowed this down to the as being caused by the commit d70f5fb0b57ad85309347607b4f15f3371361cf4 . Reverting the line as displayed below does indeed resolve it, and the highlighting of vim-color-css seems to not be affected, at least at first glance.

+	call substitute( join( getline('w0','w$'), "\n" ), b:css_color_pat, '\=s:create_syn_match()', 'g' )
-	call filter( range( line('w0'), line('w$') ), 'substitute( strpart( getline(v:val), col([v:val, left]), width ), b:css_color_pat, ''\=s:create_syn_match()'', ''g'' )' )

Aryailia avatar Aug 14 '22 20:08 Aryailia