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

Split string literals into multiple lines #724

Open
ahoppen opened this issue Apr 24, 2024 · 2 comments
Open

Split string literals into multiple lines #724

ahoppen opened this issue Apr 24, 2024 · 2 comments

Comments

@ahoppen
Copy link
Contributor

ahoppen commented Apr 24, 2024

Formatting a long string literal single line even though it exceeds the line limit. We should break it up into multiple lines, probably into a multi-line string literal

"some very long string literal that just goes on and on and one without having any real content but it reaches past the line limit"

Should become

"""
some very long string literal that just goes on and on and one without having \
any real content but it reaches past the line limit
"""
@ahoppen
Copy link
Contributor Author

ahoppen commented Apr 24, 2024

Synced to Apple’s issue tracker as rdar://126967237

@allevato
Copy link
Collaborator

I've been fairly opinionated that for comment wrapping, I'd like to use swift-markdown to re-render comments instead of just implementing something that breaks on spaces. But for string literals, maybe just breaking on spaces is enough.

Do all of Apple's developer tools that scan source files handle multi-line strings well? IIRC, at some point in the past the localized string extractor didn't like them, which was part of our reasoning for not touching them at the time.

We should also nail down the exact desired breaking behavior. Should we only split lines around whitespaces? For example, something like this is still valid, but makes it harder to work with the URL because you can no longer just click on it in most editors:

"""
http://mycoolwebsite.com/directory/\
somepage.html
"""

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