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

Allow a comment in code to explicitly configure the page width. #1574

Merged
merged 3 commits into from
Oct 5, 2024

Conversation

munificent
Copy link
Member

If the code being formatted contains a comment anywhere in it like:

// dart format width=123

Then the code is formatted at that width instead of the default width.

The intent is that tools that generate code and then format it will put this comment in the generated code. That way, the tool doesn't have to handle the complex logic to find a surrounding analysis_options.yaml file and get the user's project-wide page width configuration.

End users may also want to use this comment in rare cases. For example, maybe they have a library that contains a large value of data that looks better as a big wide table but they don't want their entire project to have a wider page width.

If the code being formatted contains a comment anywhere in it like:

```
// dart format width=123
```

Then the code is formatted at that width instead of the default width.

The intent is that tools that generate code and then format it will put
this comment in the generated code. That way, the tool doesn't have to
handle the complex logic to find a surrounding analysis_options.yaml
file and get the user's project-wide page width configuration.

End users may also want to use this comment in rare cases. For example,
maybe they have a library that contains a large value of data that looks
better as a big wide table but they don't want their entire project to
have a wider page width.
lib/src/front_end/comment_writer.dart Outdated Show resolved Hide resolved
test/tall/other/format_width.unit Outdated Show resolved Hide resolved
@munificent munificent merged commit fb00aab into main Oct 5, 2024
7 checks passed
@munificent munificent deleted the page-width-comment branch October 5, 2024 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants