-
Notifications
You must be signed in to change notification settings - Fork 228
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 trim whitespace-only lines #801
Comments
Synced to Apple’s issue tracker as rdar://135215957 |
Out of interest, what's your use case for keeping whitespace on blank lines only? |
I love being able to arrow down/up or click on empty lines that are already correctly indented. Makes the editing experience feel more "solid" if that makes sense. |
My personal feeling on this is that editors that want to provide that functionality should provide a "virtual cursor" where the user can navigate to a location outside the document's horizontal bounds, but only if they start typing there does it insert the spaces. (Naturally, that's out of scope for this project.) Always inserting spaces to fill up otherwise blank lines just feels wasteful. |
I completely agree with this opinion. In my opinion, if we would like the formatting to behave exactly like Xcode, it might be better to also insert spaces on empty lines according to the indent level. But if the intention is to reduce unnecessary actions, it may be more appropriate to only adjust lines that have incorrect amounts of whitespace to match the indent level. 🤔 |
IMO matching Xcode is a non-goal here. But if there's general interest for this in and of itself, we should definitely consider adding it. The next question there is whether we need both options ("remove trailing whitespace" and "indent blank lines"), or whether just the latter is enough. My preference would be just the latter.
I feel somewhat similar, though it's entirely possible that someone could be using very lightweight editors without this sort of feature. It would also mean that the editor has to understand how to indent (though maybe that's as simple as "match previous line"). |
I understand. Since the person who suggested the feature also needs blank line indentation, I'll implement that. |
The only thing holding me back from adopting swift-format is the inability to allow trailing whitespace in whitespace-only lines. This is my favorite Xcode feature!
Can we change PrettyPrinter to keep the surrounding context's indentation for empty lines, or would that be a breaking change? Can we add something that's based on a configuration to PrettyPrinter? I would love to get the ball rolling if someone can point me to the right place to implement this.
The text was updated successfully, but these errors were encountered: