-
Notifications
You must be signed in to change notification settings - Fork 297
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
[Bug] Incorrect angle bracket matching #469
Comments
Also, matching on angle brackets is the most uncommon thing to do in Rust IMO. |
Matching on angle brackets is very common, due to generics, and the false positives are not particularly common. The current behaviour is certainly imperfect, but historically I and multiple others have found it considerably better than not adding However, it just occurred to me that we can probably do better with matchit.vim, by ignoring left angle brackets preceded by whitespace as very probably the less-than operator rather than generics: setlocal matchpairs-=<:>
let b:match_words = " \\@<!<:>" (You could put this in an after/ftplugin/rust.vim independent of what we decide here, incidentally.) However, this only works if you have loaded matchit.vim (e.g. I’m inclined to suggest roughly this for ftplugin/rust.vim (plus a corresponding b:undo_ftplugin change): -setlocal matchpairs+=<:>
+if exists("loaded_matchit")
+ let b:match_words = " \\@<!<:>"
+else
+ setlocal matchpairs+=<:>
+endif However, this does come at the cost of no longer highlighting matching generic angle brackets, which I’m not enthusiastic about, but it might be a reasonable cost. I seek others’ opinions. |
I use matching on |
I have no intention that we should remove angle bracket matching for generics. I’m open to us improving the heuristic via Angle brackets for generics are regularly nested, though to be sure there are plenty of code bases that will never experience this. Spreading across multiple lines is fairly irrelevant (that’s not all matching is for), but even then I’d say it’s not rare to have generic angle brackets spread across multiple lines, though it’s certainly not common, with If you want to revert anything any plugin is doing, look at |
rust.vim version: latest
It treats the angle brackets of the comparison operators as valid to match on, which is incorrect.
Steps to reproduce:
If we put the cursor on any of the brackets above, it will match.
Expected vs. actual behavior:
Expectation: Use
matchpairs
defined by the user.Reality: rust.vim decides to do
setlocal matchpairs+=<:>
for whatever reason.Debug info:
The text was updated successfully, but these errors were encountered: