Skip to content
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

Disable dart format for one line (or a range of lines) #1242

Open
fzyzcjy opened this issue Jul 6, 2023 · 4 comments
Open

Disable dart format for one line (or a range of lines) #1242

fzyzcjy opened this issue Jul 6, 2023 · 4 comments

Comments

@fzyzcjy
Copy link

fzyzcjy commented Jul 6, 2023

This will be very helpful for, for example, Flutter repository itself. The current auto-formatter is not used by Flutter because sometimes its format makes code not very readable, and in this case, something like // dart-format-please-ignore-the-following-line would be very helpful.

I heard this is being worked on, but I googled and searched the issues without finding one, thus I create an issue here.

Related: https://discord.com/channels/608014603317936148/608018585025118217/1126403478424666154

@munificent
Copy link
Member

munificent commented Jul 13, 2023

I'm not working on it yet, but, yes I've come around to the idea that this is worth doing. Thanks for filing the issue. :)

@Reprevise
Copy link

Came here to open an issue similar to this, I'd love to see something like this:

// formatter(ignore)
const matrixValues = [
  1, 0, 0, 0, 0,
  0, 1, 0, 0, 0,
  0, 0, 1, 0, 0,
  0, 0, 0, 1, 0
];
// formatter(end-ignore)

Anyone who's worked with ColorFilter.matrix() knows the pain of the formatter putting each double value on a new line

@mrcnski
Copy link

mrcnski commented Jan 31, 2024

Here's another use case. dart format changes this:

print("  error: line $e.lineNum: '$e.line'");
print("         ${e.originalException.runtimeType}: ${e.originalException.toString()}");

to this:

print("  error: line $e.lineNum: '$e.line'");
print(
    "         ${e.originalException.runtimeType}: ${e.originalException.toString()}");

I'd like to preserve the first version, with the strings nicely lined up, to be able to see the output formatted the same way the user would see it!

@munificent
Copy link
Member

In that specific case, an easier fix is simply:

print("  error: line $e.lineNum: '$e.line'");
print("         ${e.originalException.runtimeType}: ${e.originalException}");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants