Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matching Curly Brace Highlight Wrong #146

Open
hdon opened this issue Sep 28, 2017 · 10 comments
Open

Matching Curly Brace Highlight Wrong #146

hdon opened this issue Sep 28, 2017 · 10 comments

Comments

@hdon
Copy link

hdon commented Sep 28, 2017

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!

@BurningLutz
Copy link
Contributor

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.

@hdon
Copy link
Author

hdon commented Oct 12, 2017

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

@davidosomething
Copy link

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

@ajcrites
Copy link

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

@navargas
Copy link

navargas commented Mar 4, 2018

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

@redbmk
Copy link

redbmk commented Mar 19, 2018

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
Copy link

redbmk commented Mar 19, 2018

@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 added a commit to redbmk/vim-jsx that referenced this issue Mar 19, 2018
@redbmk
Copy link

redbmk commented Mar 19, 2018

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.

@chemzqm
Copy link

chemzqm commented May 13, 2018

The reason is in line

syn region xmlString contained start=+{+ end=++ contains=jsBlock,javascriptBlock
and
syn region jsxChild contained start=+{+ end=++ contains=jsBlock,javascriptBlock

make { and } have different syntax group.

@michaeltintiuc
Copy link

Seems like this is still happening?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants