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.

Formatter should indent wrapped imports to same alignment as previous line

See original GitHub issue
use piston_window::{Button, clear, Context, Event, Input, Key, PistonWindow, text, types,
    Transformed};

Should be formatted to

use piston_window::{Button, clear, Context, Event, Input, Key, PistonWindow, text, types,
                    Transformed};

According to rustfmt 0.6.3:

 use piston_window::{Button, clear, Context, Event, Input, Key, PistonWindow, text, types,⏎
-    Transformed};⏎
+                    Transformed};⏎

@matklad Is the goal of the intellij-rust formatter is to default to what rustfmt does? Just want to make sure I’m not reporting issues that aren’t actually in scope for where intellij-rust wants to go (but I assume this would be a positive).

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
matkladcommented, Jan 16, 2017

Is the goal of the intellij-rust formatter is to default to what rustfmt does?

Yes!

0reactions
alygincommented, Jan 17, 2017

rustc (and I think cargo as well) uses some checks to find out if it’s running in an environment that supports colors. If not, the colored output is suppressed. But you can force it by passing the --color=always option to the command (or explicitly suppress it by passing --color=never).

Cargo also supports the --color option, but it relies on other programs. For instance, cargo build executes rustc and passes some of its own options to the compiler, including --color (if it has been specified explicitly). But when you execute cargo clippy, the --color option is not passed to rustc (which is the actual clippy’s engine) because cargo treats clippy as a pluggable command and makes no assumptions on what options it supports.

So, cargo build --color=always forces colored output in the underlying rustc command, while cargo clippy --color=always does not.

The IntelliJ command output window handles output in a special way (for instance, it paints all the stderr output red), so we have to reconfigure it a bit and add the --color=always option every time we run a command that we know supports colored output.

The IntelliJ terminal (and the outside one) works another way and is treated by rustc (as well as by cargo) as color-friendly. So, no additional actions needed to force colors.

I don’t know, what exactly is the difference in implementation of these two windows. Maybe Alexey can answer this. But the fact is that when you execute cargo clippy --color=always, the underlying rustc command remains unaware of this --color option, so it fully relies on its checks (mentioned above) that fail to recognise the IntelliJ command output window as suitable for colored output. And here we are, with the red stderr text.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I control indentation of wrapped lines in Visual Studio
So, frequently wrapped line starts at character 80 or 90! How can I make it always indent 4 characters from the previous line?...
Read more >
SwiftFormat/Rules.md at master
A command-line tool and Xcode Extension for formatting Swift code - SwiftFormat/Rules.md ... Wrap braces in accordance with selected style (K&R or Allman)....
Read more >
Code Style. Java | IntelliJ IDEA Documentation
Use this page to configure formatting options for Java files. ... IntelliJ IDEA will keep indents on the empty lines as if they...
Read more >
Coding Conventions - Apache PDFBox
Wrapped lines should use either an indent of 4 or 8 characters or align with the expression at the same level on the...
Read more >
Configuration · Scalafmt
If true , lines starting with the margin character | (or another if specified in the .stripMargin(...) call) will be indented differently. If...
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