-
Notifications
You must be signed in to change notification settings - Fork 8
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
Format previous line on 'Enter' key #43
base: main
Are you sure you want to change the base?
Conversation
Great start! Though when having the following code, formatting lead to losing the indentation: SomeType()
.doSomething ( )
// was formatted to
SomeType()
.doSomething() I suppose for non-empty lines we should advance the range to the first non-whitespace character. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions, other than @vknabel 's.
This looks like a swiftformat issue -- I don't think there is a workaround. Added it to the end of nicklockwood/SwiftFormat#1738. I don't think we can make this change in the extension until swiftformat fixes the corresponding issue, otherwise it may be too disruptive for users. |
@vinocher-bc ppssibly we can see how many spaces are at beginning of the line before format, and add them back after the format too each new line of the formatted text? |
When the 'Enter' key is pressed, format the previous line because the user has usually moved to a new empty line. This is the most common scenario.
Also, format only the previous line instead of the entire document for better performance and because formatting the entire doc may conflict with
"editor.formatOnSaveMode": "modifications"
(See Only format modified text.)Previously, the entire document was formatted if the new line was non-empty.