question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do not insert matching }

See original GitHub issue

Although I’m very happy with intellij-rust, one feature annoys me.

Intellij-rust inserts {} when I type {. It is annoying, because most of the time I need to erase that matching brace.

E. g. I have a code like this:

match foo {
  Bar(x) <CURSOR HERE> if x => 1,
}

I want to type => { at cursor position to convert code to:

match foo {
  Bar(x) => { if x { 1 } else { 2 } },
}

However, Intellij-rust inserts:

match foo {
  Bar(x) {} if x => 1,
}

so I need to immediately erase }.

Also, intellij-rust is very good at inserting matching } when I press Enter, e. g. in this case:

match foo {
  Bar(x) {<CURSOR HERE if x => 1,
}

So matching } right after { is almost never needed.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
alygincommented, Mar 20, 2017

I never paid much attention to that, but for Java, IDEA only inserts matching }s in some predefined contexts. Unfortunately, it sometimes doesn’t insert them when I would expect it to do, but at least it doesn’t annoy me when I do some nontrivial refactoring. Kotlin only analyzes the following symbol, CLion seems to not care about it at all and just throws } everywhere.

What do you think about such approach: try to insert a } and if it causes a syntax error nearby, remove it? I never looked into this part of the plugin, so not sure if there could be a reliable implementation.

2reactions
matkladcommented, Mar 21, 2017

This option also stops inserting matching ‘(’ and ‘[’ which works well. But thanks anyway.

Yeah, I think we need just to be more smart and do the same thing that Java does. I am in general against adding more options, I would prefer IDE to just do the right thing.

By the way, @la10736 there’s a nice option “surround selection on typing quote or brace”, which is a little bit nicer to use than surrounders.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to disable automatically adding a closing curly brace or ...
I don't want it to auto insert any closing character or any indentations. I basically just want it to stop helping me and...
Read more >
auto closing brackets not working on vscode 1.57 #127739
Steps to Reproduce: open a js file on code; type a opening bracket (; expected result (); actually getting (; bracket is not...
Read more >
How disable auto closing of brackets, quotes, curly braces etc ...
I have disabled 'Insert pair quote' but it still auto-closes quotes in css files and within the css-section of the SmartKeys-Options, there is...
Read more >
Insert () and Closing } ) ] ' " - Documentation for Visual Assist
Visual Assist places your caret between the parentheses if your selection takes an argument, and after if not. Press Undo to revert the...
Read more >
VS Code tips — The Auto Closing Delete setting - YouTube
Today's VS Code setting: Auto Closing DeleteConfigure what the delete ... Don't delete anything • always — Always delete matching brackets.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found