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

Column limits don't seem to apply to comments #469

Open
dabrahams opened this issue Jan 9, 2023 · 7 comments
Open

Column limits don't seem to apply to comments #469

dabrahams opened this issue Jan 9, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@dabrahams
Copy link
Contributor

Description

I want column limits respected even in comments, and I want them to be automatically line-wrapped, preserving markdown semantics within doc comments.

Steps to Reproduce

Run swift-format lint on:

// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789

It should complain, but does not.

@dabrahams dabrahams added the bug Something isn't working label Jan 9, 2023
@allevato
Copy link
Member

allevato commented Jan 9, 2023

Did you mean to file this over at apple/swift-format?

The current behavior is WAI, but I'd like to make improvements here. Treating comments as Markdown resolves the majority of my concerns around formatting comments (a long URL? Markdown will still preserve it past the line limit. Some fancy ASCII art diagram? Wrap it in triple-backticks to preserve it), but we'll need semver releases over at https://github.com/apple/swift-markdown before we can adopt it.

@dabrahams
Copy link
Contributor Author

dabrahams commented Jan 9, 2023

Did you mean to file this over at apple/swift-format?

Uh, yeah. Can it be moved? Should I refile?

WAI

?

@allevato allevato transferred this issue from swiftlang/swift-syntax Jan 10, 2023
@allevato
Copy link
Member

Did you mean to file this over at apple/swift-format?

Uh, yeah. Can it be moved? Should I refile?

I've transferred it over.

WAI

?

Working as intended (under the constraints today, which is that I don't want us to implement our own line-breaking logic for prose, and using swift-markdown would fix that).

@ahoppen
Copy link
Member

ahoppen commented Apr 23, 2024

Tracked in Apple’s issue tracker as rdar://126948257

@shawnhyam
Copy link
Contributor

I tried using swift-markdown to format doc comments, and while the results were mostly good, there was one issue in particular that really broke the formatting. A line like this:

/// The break maintains the existing value of `currentLineIsContinuation` when it fires.

would get reformatted as:

/// The break maintains the existing value of
///
///
/// `currentLineIsContinuation` when it fires.

Whenever the line would wrap on a piece of text that was enclosed in a backtick, it would treat it as a new paragraph. There were some other issues with double line breaks for new paragraphs, and using blank spaces instead of backslash for line continuations (which are in danger of being removed by the editor), but this was the biggest problem.

@allevato
Copy link
Member

That looks like it would be a bug in swift-markdown, because an inline node shouldn't cause a paragraph break like that. If you can repro it standalone, can you file an issue over there and see what they say?

@shawnhyam
Copy link
Contributor

Issue created: swiftlang/swift-markdown#197

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants