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

Option(s) to remove trailing whitespace in multiline strings, comments #784

Open
2 tasks
mortenpi opened this issue Nov 27, 2023 · 2 comments
Open
2 tasks

Comments

@mortenpi
Copy link

JuliaFormatter doesn't remove whitespace in multi-line strings (where it is semantically significant), nor in comments. This is two related, but potentially distinct asks:

  • Removing trailing whitespace in comments. Not entirely sure what the rationale is for not removing it in comments by default? Regardless, feels like minimally there should be an option for it.
  • Opt-in option for removing the semantically significant whitespace in multi-line strings. Theoretically, that whitespace is significant, but in practice it almost never is, and can be stripped (in fact, that might be preferred -- being significant, that whitespace might actually cause bugs). When used in a project that consistently enforce the formatter, this should never cause issues with this changing the program's behavior.

The gripe that motivates this feature request for me is that JuliaFormatter isn't fully consistent with the Trim Trailing Whitespaces functionality in VS Code, and it's often quite annoying to fix up the leftover whitespace from other PRs that JuliaFormatter didn't catch.

X-ref: #351

@domluna
Copy link
Owner

domluna commented Dec 5, 2023

yeah this seems reasonable. I'd be open to a PR for it. It shouldn't be that much work to implement

comments could be done in print.jl

for docstrings adding trimming before this should work https://github.com/domluna/JuliaFormatter.jl/blob/master/src/styles/default/pretty.jl#L416-L418

you might have to adjust the offset too but I'm not sure

@domluna
Copy link
Owner

domluna commented Dec 5, 2023

it is works when it might as well be on btw. I don't see why this would be optional assuming it doesn't break anything

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

No branches or pull requests

2 participants