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

Don't insert unnecessary (double) space for // inline comments #868

Closed
ktoso opened this issue Oct 30, 2024 · 6 comments
Closed

Don't insert unnecessary (double) space for // inline comments #868

ktoso opened this issue Oct 30, 2024 · 6 comments

Comments

@ktoso
Copy link

ktoso commented Oct 30, 2024

Swift-format has this really weird behavior of adding an "extra" space for inline comments:

Screenshot 2024-10-30 at 19 07 50

from:

hello() // says hello

to

hello()  // says hello

This is pretty weird and should not be happening.

@allevato
Copy link
Member

FWIW, offsetting EOL comments by 2 spaces is just a typographic/style choice that isn't any weirder than the others 🙂

As of #776, it can be controlled by the spacesBeforeEndOfLineComments configuration setting. I believe it's only available in the 601.0.0 prereleases, though.

@ktoso
Copy link
Author

ktoso commented Oct 30, 2024

Across a bunch languages I worked with this is the first time seeing this so it’s at least uncommon in that sense.

Good to hear it’s configurable now but pretty the downside nowadays being that the releases are tied to swift hm… so it means 6.1 for this I think, that’s fine.

We can probably consider this solved by that configuration option, though I’d argue it’s definitely an unprecedented default behavior. I’ve never seen a language or style guide suggest this and I’ve worked with quite a few languages. It’s one more “swift is weird” that we’ll keep getting told as we migrate more and more developers from other ecosystems - so that’s why I think it matters, as we already have an uphill battle with such folks coming over sometimes 💭

@ahoppen
Copy link
Member

ahoppen commented Oct 30, 2024

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

@ktoso
Copy link
Author

ktoso commented Oct 30, 2024

Heh, with further reading I found this is specifically the Google-way https://google.github.io/swift/

I'd be iffy about imposing that specific rule... but since it's configurable I guess we can leave it at that.

@allevato
Copy link
Member

If we can get the entire community to agree on any set of rules, I'm happy to change them 😅

@ahoppen
Copy link
Member

ahoppen commented Oct 30, 2024

Let’s close this issue because we have configuration option for it (#776).

@ahoppen ahoppen closed this as completed Oct 30, 2024
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

3 participants