jackguo380 / vim-lsp-cxx-highlight

Vim plugin for C/C++/ObjC semantic highlighting using cquery, ccls, or clangd
MIT License
337 stars 26 forks source link

Preprocessor excluded regions aren't properly rehighlighted after removed #61

Closed rgreenblatt closed 2 years ago

rgreenblatt commented 3 years ago
#include <iostream>

int main()
{
#ifdef TOTALLY_NOT_DEFINED
  std::cout << "hello world\n";
#endif

}

If you remove the ifdef, then the << "hello world\n" isn't highlighted properly (it remains grey).

image

It seems that the corresponding highlight group isn't being removed (or similar).

I am using ccls (official arch package) with clang 11.1, neovim, and coc.nvim.

If this can't be reproduced easily let me know and I will add log files and create a minimal configuration which reproduces this.

jackguo380 commented 3 years ago

Hi greenblatt,

Thanks for reporting this, it was fairly easy to reproduce. I have pushed a fix onto master, could you test it out and see if it fixes your issue?

Thanks.

rgreenblatt commented 3 years ago

Yep, looks like this is fixed, thanks!

jackguo380 commented 3 years ago

Reopening as ce92c8e9b1ab587eb22ad017d536619b6a100d09 seems to have caused a regression.

The highlighting flashes on saving which is worse than having leftover highlights so I am going to revert this fix for now and come up with a better one.

The cause seems to be that ccls is sending an empty notification immediately after saving and then sending the real highlighting after finishing analyzing (usually 500ms to a few seconds depending on file size).