Happens only in .rs files and only when the Rust extension is enabled. I have tested with all other extensions disabled and the Rust extension disabled / enabled.
Rust: 0.7.8
Version: 1.45.1
Commit: 5763d909d5f12fe19f215cbfdd29a91c0fa9208a
Date: 2020-05-14T08:27:22.494Z
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Linux x64 5.4.0-29-generic (kubuntu 20.04 if that matters)
Reproduction:
.rs extension.this is not supposed to be a bug, but a feature https://github.com/rust-lang/rls-vscode/issues/719 :sweat_smile:
I see.. I mean I can see how it is useful, but it is also annoying.
In the language-configuration.json where the auto closing pairs are defined, there are some "brackets" that don't work in strings via the notIn key. Is there a similar key available that says "only auto close this pair if the character before the open bracket is not a whitespace character"? That would solve the problem for me. Because things like Impl<, would still autocomplete, but things like x < won't.
Very good idea. Found it annoying in comparisons as well.
AFAIK the docu doesn't allow this use-case. But not sure what notIn allows
I guess I will just have to remove that from my configuration locally.
I find this behaviour annoying too.
But I'm only a beginner in Rust.
Maybe it'll be useful when I get to the generics stage.
This should be reopened. Don't automatically insert a > when it's not certainly useful, as in the case of
if n <
which turns into
if n <>
@mightyiam #720 comment Apparently rust coders write much more generic code than comparisons. For what it's worth, the workaround I mentioned in this comment (removing the autoclosing pair from the language-configuration in your install) works. ...or you could invert the comparisons, n < 5 to 5 > n, that's probably ugly though.
@scimas can't this be fixed? Is the extensions API lacking?
No idea, as you can see this issue was open for 4 days before it received any reply. And even the replying account is a ghost now.
The vscode documentation of language-configuration lists an autocompleteBefore setting, which defaults to whitespace. Meaning that ( gets autocompleted to () but adding ( before xyz doesn't make it ()xyz. If there was an equivalent autocompleteAfter it would be easy. Basically we could tell it to autocomplete the angular bracket only if it is _not_ next to whitespace. So impl< becomes impl<> but n < doesn't become n <>. But there isn't.
Anything more would require something custom made by this extension (this is my guess, I am not at all familiar with how the extensions or language servers work).
I'm having the same issue. This is especially annoying when typing algorithms and conditions with lots of comparison operators. I don't know if there's a way to change language config locally. If there is I'll be pleased to disable that until a more complex autocompletion rule like scimas proposed gets implemented.
Edit: I don't think I had the issue before very recently on my client, I don't know if it's part of a recent patch to the rust language extension.
This is really annoying and ridiculous, Please don't do this to rust beginners like me.
If I type < it will become <>,
if i replace > with = it will become >= not <=.
???
Most helpful comment
I see.. I mean I can see how it is useful, but it is also annoying.
In the
language-configuration.jsonwhere the auto closing pairs are defined, there are some "brackets" that don't work in strings via thenotInkey. Is there a similar key available that says "only auto close this pair if the character before the open bracket is not a whitespace character"? That would solve the problem for me. Because things likeImpl<, would still autocomplete, but things likex <won't.