Skip to content

Better Format Selection #27

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

Closed
MahdiBM opened this issue Aug 10, 2023 · 4 comments
Closed

Better Format Selection #27

MahdiBM opened this issue Aug 10, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@MahdiBM
Copy link
Collaborator

MahdiBM commented Aug 10, 2023

When you do "Format Selection" in VSCode, it'll format the selection out of context of the file, which can make it look weird because it won't properly take care of indentation etc...

It should instead take the whole file context into account, but only modify the selected lines.

Steps to reproduce

1:

Screenshot 2023-08-11 at 2 32 17 AM

2:

Screenshot 2023-08-11 at 2 32 24 AM

3:

Screenshot 2023-08-11 at 2 32 34 AM

4:

Screenshot 2023-08-11 at 2 32 48 AM

As you can see, in 4 indentation of the function is broken compared to the parent struct. There is also a weird extra space below the function after the indentation, not sure why.

Usage?

When working on team projects you might want to keep your own code-style clean, but don't force it on others.
Without a feature like this you always need to format the whole file instead of just the few lines you wrote.

@vknabel
Copy link
Owner

vknabel commented Aug 11, 2023

Thanks for opening this issue! I totally get the use case and I definitely will have a look on this.

@vknabel vknabel self-assigned this Aug 11, 2023
@vknabel vknabel added the bug Something isn't working label Aug 11, 2023
@MahdiBM
Copy link
Collaborator Author

MahdiBM commented Aug 14, 2023

I just noticed this issue in swift-format repo: swiftlang/swift-format#297.
I thought it doesn't hurt to mention that they basically want to natively support what this issue requests.

@MahdiBM
Copy link
Collaborator Author

MahdiBM commented Aug 22, 2023

I just notice this is the repository for Nick Lokwood's swift-format, but actually that makes the issue even better because i've now moved to the Nick Lockwood's swiftformat because Apple's swift-format doesn't seem actually useable in practically formatting stuff properly.

@vknabel
Copy link
Owner

vknabel commented Sep 16, 2023

Thanks for the upcoming comments!
If I get this right, there is no issue in this repo and for the apple formatter extension, this is an upstream issue.

@vknabel vknabel closed this as completed Sep 16, 2023
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

No branches or pull requests

2 participants