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.

Same color if/else/for/while/switch statement's parentheses and its first curly brackets

See original GitHub issue

You should Star this repo before you create a issue, thanks for your support 😁 Done!

Expected Behavior

  • The first curly brackets should have the same color as the parentheses: image (screenshot from VS Code)

Current Behavior

  • The first curly brackets have a different color from the parentheses: image (screenshot from WebStorm)

Possible Solution

The plugin could keep count of the block-level and use the same color for each level. In the example the yellow block-level started with ( and was closed with ) so the next set of braces are at the same block-level, thus can reuse the yellow color.

Or perhaps it’s easier to just hardcode this rule for these type of statements.

Code snippet for reproduce (for bugs)

if (foo === "bar") {
  // curly braces get the same color as the parentheses
}

Your Environment

  • Plugin version: 5.0-RC3
  • IDEA version: WebStorm 2018.1 EAP, WS-181.4096.25, built on March 8, 2018
  • Operating System and version: macOS 10.13.x

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Alexseycommented, Mar 16, 2018

I mean that with this change to determine what should be the color of the bracket just knowledge about the color of the closest bracket of the same type would not be enough - it would require also to take the color of different brackets in to account as well. Now consider that brackets of the same type should have the same color

function foo () { // blue
  if (bar) return // blue
  if (baz) { // this one should be orange. And this should also change the color of the first "if"
    ...
  }
}
0reactions
izhangzhihaocommented, Mar 27, 2018

I’m going to close this issue, feel free to re-open it or raise a new one if you have any issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When should I use curly braces { } and parenthesis ( ) in React?
Curly braces { } are special syntax in JSX. It is used to evaluate a JavaScript expression during compilation. A JavaScript expression can...
Read more >
Assignment of several statements enclosed in parentheses ...
Behind the magic is a GCC C extension, which causes a code block to return a value if enclosed within brackets and parentheses....
Read more >
26/30, no curly brackets after "if" and "else" ? | Codecademy
Yes it is not necessary to use curly braces after conditions and loops (functions always need them) IF and only if there is...
Read more >
Noob: don't understand usage of curly brackets in if-statement
I think there's a misunderstanding: if (true) { x } { y } is exactly the same as if (true, { x },...
Read more >
Adding color to bracket pairs - Visual Studio Blog
We call it Rainbow Braces and the first iteration adds basic colorization to curly brackets, square brackets, and parentheses (see image ...
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