-
Notifications
You must be signed in to change notification settings - Fork 29k
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
editor.formatOnSaveMode
does not appear to function
#105800
Comments
@alexdima modifications are based on SCM diff information. Your file appears as untracked and no quick diff markers show. Do you really have only those lines "SCM modified"? |
@misolori you are on the right path. Modifications are being formatted but my assumption is that I pass the range 10,1-11,1 to the html formatter and that it then over-eagerly formats the whole statement of line 11. @alexdima ping for clarification |
@jrieken I see, I misunderstood the feature. Maybe the setting could make it more clear that this is only about SCM diff ranges. I thought that the file is read from disk just before saving and a diff is computed with the state on disk. It was not clear to me that the diff is computed with the state of the index. |
The setting says "requires source control"... I actually like your assumption of how it should/could work and that's maybe something for the future. So, maybe we find an alternative for "modified" that expresses it's "source control modified" and then, in the future, we have another option that says "modified in session". Ideas? |
Yeah, the suggestion details widget would show this... Still open for suggestion for a better name and maybe give this a short test run after all @misolori can you share the file and what formatter you are using? I wasn't able to reproduce what you see. |
So it looks like that may have been an issue with my formatter (Prettier). Disabled that and used the default one and got it working for JS files. However, I'm not seeing this work reliably with JSON files. Some format commands don't work ( |
Yeah, the secret of "format modified" is that it does "format selection" where the selection isn't visible and consists of the modified ranges. Adding @aeschli who did the JSON formatter - it might not be fit for arbitrary range formattings |
Seeing similar things with the HTML formatter. This works fine in other JS/TS files though. Hopefully these bugs can get fixed and are not by design. |
Testing #105733
file.ts
"editor.formatOnSaveMode": "modifications"
"editor.formatOnSave": true
class A
has been formatted:The text was updated successfully, but these errors were encountered: