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

undefined variable: b:css_color_pat

Open pushcx opened this issue 6 years ago • 1 comments

When switching focus away from an ALEPreviewWindow, I get the below error from vim-css-color:

Error detected while processing function <SNR>103_parse_screen:                                                                                                                             
line    4:
E121: Undefined variable: b:css_color_pat

This may be a recurrence of #32. From clues there, maybe it's related to me having this (admittedly a little janky) .vimrc config to keep the ALEPreviewWindow updated with the error/warning under the cursor:

augroup ALEDetailUnderCursor
  autocmd!
  " show the error under the cursor
  " only open the preview window for errors; fill warnings if it's open
  " winsaveview() and winrestview() prevent this from scrolling the current window
  " BUG: a second vim session errors if first sesison has detail window open
  autocmd CursorMoved *
  \ if ale#statusline#Count(bufnr('')).total !=? 0 |
  \   if ale#statusline#Count(bufnr('')).error !=? 0 || bufwinnr('ALEPreviewWindow') > 0 |
  \     let view=winsaveview() |
  \     ALEDetail |
  \     call winrestview(view) |
  \   endif |
  \ endif
  " TODO: if there's no errors, display test output
  autocmd User ALELint
  \ if ale#statusline#Count(bufnr('')).error !=? 0 |
  \   ALEDetail |
  \ elseif bufwinnr('ALEPreviewWindow') > 0 |
  \     wincmd P |
  \     setlocal modifiable |
  \     setlocal noreadonly |
  \     :%d |
  \     setlocal nomodifiable |
  \     setlocal readonly |
  \     wincmd p |
  \ endif
augroup END

pushcx avatar Nov 27 '18 13:11 pushcx

Hi, thanks for the report. Let’s see if we can figure this one out.

maybe it's related to me having this (admittedly a little janky) .vimrc config

Maybe! I don’t really spot anything in there that would lead to buffer-local variables being reset. But well, if you suspect it… have you tried disabling it and seeing if that makes the error go away? 😊(I don’t expect this to lead us anywhere, but… let’s just check it out and see if it does. Who knows.)

It’s interesting that you say it happens when you switch focus away from a preview window. That seems to mean that somehow the variable in the buffer you are switching to is somehow gone. That’s… odd. No plausible mechanism for how that could be happening comes to mind… so maybe let’s try to check assumptions. Is that the only variable that’s gone? What does the following command say right after you get the error?

:echo join(sort(filter(keys(b:),'v:val =~ "^css_color_"')),"\n")

ap avatar Dec 01 '18 20:12 ap