vim-jsx
vim-jsx copied to clipboard
Matching Curly Brace Highlight Wrong
In the first image, we see my cursor is on the curly brace on line 43, but the matched curly brace highlight is incorrectly on line 45:
Interestingly, if I jump to the matching closing curly brace with ]} key sequence, then it jumps to the correct one on line 50. Yet this time, no matching curly brace is highlighted at all:
Thanks for contributing this vim syntax!
This doesn't happen to me. Probably not a vim-jsx issue?
P.S. I use neovim as editor and vim-javascript + vim-jsx for syntax highlight.
I'll have to remember to give it a try on a vanilla install of vim
if it's the match highlight from cursor on top, i think it is an issue with matchparen.vim I am using https://github.com/itchyny/vim-parenmatch instead and it matches correctly there
This does happen to me even with itchyny/vim-parenmatch
I can reproduce this as well, using the default paren matching on this line. I noticed the problem goes away when commenting out this line.
syn region xmlString contained start=+{+ end=++ contains=jsBlock,javascriptBlock
I notice the same syntax highlighting as well. In the CRA file that @navargas pointed out, if I go to the { after render on line 6, it highlights the } after logo on line 10.
The problem is even worse in neovim, in that it not only highlights the wrong one, but if I press % it will actually go to that matched portion. In vim it will still go to the correct spot (the } on line 25 in this case).
If I remove the plugin (or do :set ft=text) the correct bracket is highlighted and the % works in both vim and neovim.
@navargas Also, changing end=+}+ in that line seems to fix it as well. Although, I don't notice any difference in coloring with that line in, out, or with end=+}+. What is it supposed to do?
The comment above mentions that jsBlock should handle the closing tag, hence the "trivial end pattern".
Regarding the color difference, that ended up just being something with my colorscheme - the difference was subtle enough that I didn't notice at first.
I only ended up seeing the correct color highlighting with the change to end=+}+, and it also fixes the curly brace highlighting as well as the % matching.
I tried every combination of the original code, commenting that line out, and adding the fix, as well as using in conjunction with vim-javascript or not. The only way that worked for me was the code change to fix end, so I ended up creating a pull request.
Hopefully this works for others as well.
The reason is in line https://github.com/mxw/vim-jsx/blob/52ee8bb9f4b53e9bcb38c95f9839ec983bcf7f9d/after/syntax/jsx.vim#L35 and https://github.com/mxw/vim-jsx/blob/52ee8bb9f4b53e9bcb38c95f9839ec983bcf7f9d/after/syntax/jsx.vim#L40
make { and } have different syntax group.
Seems like this is still happening?