vim-jsx icon indicating copy to clipboard operation
vim-jsx copied to clipboard

Matching Curly Brace Highlight Wrong

Open hdon opened this issue 8 years ago • 10 comments

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!

hdon avatar Sep 28 '17 22:09 hdon

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.

BurningLutz avatar Oct 12 '17 16:10 BurningLutz

I'll have to remember to give it a try on a vanilla install of vim

hdon avatar Oct 12 '17 19:10 hdon

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

davidosomething avatar Oct 12 '17 20:10 davidosomething

This does happen to me even with itchyny/vim-parenmatch

ajcrites avatar Feb 12 '18 22:02 ajcrites

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

navargas avatar Mar 04 '18 20:03 navargas

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.

redbmk avatar Mar 19 '18 01:03 redbmk

@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".

redbmk avatar Mar 19 '18 01:03 redbmk

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.

redbmk avatar Mar 19 '18 02:03 redbmk

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.

chemzqm avatar May 13 '18 14:05 chemzqm

Seems like this is still happening?

michaeltintiuc avatar Feb 27 '19 00:02 michaeltintiuc