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

Using formatter findent with format code on save produces error "Failed to save" file #364

Closed
maroony opened this issue Jan 19, 2022 · 10 comments · Fixed by #293
Closed
Assignees
Labels

Comments

@maroony
Copy link

maroony commented Jan 19, 2022

Describe the bug
When using the formatter findent with option "editor.formatOnSave": true, every time I got the following error message:

Failed to save 'file.f90': The content of the file is newer. Please compare your version with the file contents or overwrite the content of the file with your changes.

I do not get this error when using formatter fprettify which is very slow in compare to findent.

To Reproduce
Steps to reproduce the behavior:

  1. Open file.f90
  2. Make a change in this file
  3. Hit key command for saving the file (e. g. Ctrl + S)
  4. Get the error message

Expected behavior
Saved formatted file.

Build info (please complete the following information):

  • Linux x64 (Remote Development)
  • Extension Version 2.6.2
  • Visual Studio Code Version 1.63.2

Additional context
Add any other context about the problem here.

@maroony maroony added the bug label Jan 19, 2022
@gnikit
Copy link
Member

gnikit commented Jan 19, 2022

Yeah, we have not implemented formatOnSave yet. I can't seem to remember why I didn't but the fix "should" be trivial, we only have overload an internal VS Code function with the existing one.

@gnikit gnikit self-assigned this Jan 19, 2022
@trybik
Copy link

trybik commented Jan 25, 2022

Bumping up this issue - at least some error-handling, as this is a very annoying and confusing error to get if you have formatOnSave globally enabled.

@gnikit
Copy link
Member

gnikit commented Jan 25, 2022

Does setting up the formatter to "Disabled" for the extension solve the issue?

@trybik
Copy link

trybik commented Jan 25, 2022

Does setting up the formatter to "Disabled" for the extension solve the issue?

if you mean setting "editor.formatOnSave": false, then yes, it does prevent the error pop-up

@gnikit
Copy link
Member

gnikit commented Jan 25, 2022

No, I mean the extension's settings for formatting: "fortran.formatting.formatter": "Disabled",. If that does not stop it, for the time being you can setup workspace specific settings which take precedence over your global ones.

@HamGhibli
Copy link

Hi, I had similar issue today.
So locally, in the folder's /.vscode/settings.json, setting : { "editor.formatOnSave": false } solves the issue.
However, if we try locally the following settings enabling the formatOnSave while disabling fortran formatting,:
{
"editor.formatOnSave": true,
"fortran.formatting.formatter": "Disabled"
}

the issue is still there !

as additional info, I am using:

  • Ubuntu 20.04.3
  • Vscode 1.63.2
  • Modern Fortran Extension v2.6.2

@gnikit
Copy link
Member

gnikit commented Jan 25, 2022

enabling the formatOnSave while disabling fortran formatting,

Thanks @HamGhibli that's what I wanted to know. BTW are you sure that version 2.6.2 has that option present. I think this should only be available in the pre-release version where I did a major rewrite of the interface.

I am slightly short on time so any volunteers for this would be appreciated.

@terrry-sh
Copy link

Hey guys I implemented a potential fix here: #370. Please let me know how it is

@HamGhibli
Copy link

@gnikit thanks for the reply. I did not switch to the pre-release version yet...

gnikit added a commit that referenced this issue Jan 26, 2022
This is a proper async implementation of the formatting interface for
simple edits. It can be extended to ranges as well, with minimal code.

Closes Using formatter findent with format code on save produces error "Failed to save" file #364
@gnikit
Copy link
Member

gnikit commented Jan 26, 2022

I have issued a fix as a pre-release, I would NOTE the different interface that we have adopted in the extension.

@gnikit gnikit closed this as completed Jan 26, 2022
@gnikit gnikit linked a pull request Jan 26, 2022 that will close this issue
8 tasks
@gnikit gnikit mentioned this issue Jan 26, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants