p00f / nvim-ts-rainbow

Rainbow parentheses for neovim using tree-sitter. Use https://sr.ht/~p00f/nvim-ts-rainbow instead
Apache License 2.0
869 stars 67 forks source link

Lines with inline comments get wrong color #145

Closed Gordin closed 1 year ago

Gordin commented 1 year ago

Describe the bug

When there is an inline comment at the end of a line, the color of the brackets will be different from the other lines. Tested it lua and python. Happens for all lines with comments, not just the first one.

Steps to reproduce Open a file with the code below

    { name = 'luasnip', priority = 9 }, -- For luasnip users.  
    { name = 'nvim_lua', priority = 8 },
    { name = 'nvim_lsp', priority = 8 },
    { name = 'path', priority = 8 },
x = {
    "bla": {1: 2}, # bluaoeu
    "blub": {3, 4}
}

It stays wrong even after doing TSDisable rainbow TSEnable rainbow. It does fix itself, though, when you put a pair of brackets inside the one with the wrong color and delete it again.

Expected behavior Colors should be the same

Screenshots WindowsTerminal_tCfDUdlSYQ WindowsTerminal_zezZruLtFZ

Gordin commented 1 year ago

FYI, I tried to debug this myself, and it seems like it's actually not the wrong color, it's just not using Rainbow colors at all for lines with comments image

After that, I searched the code for comment, removed one line and that fixes it... #147