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

export format package #762

Closed

Conversation

ghentschke
Copy link
Contributor

This package is needed in DocumentProviders of LSP based editors to support the format on file save action. Only needed for servers who do not support willSaveWaitUntil

fixes #761

This package is needed in DocumentProviders of LSP based editors to
support the format on file save action. Only needed for servers who do
not support willSaveWaitUntil

fixes eclipse-lsp4e#761
@ghentschke
Copy link
Contributor Author

I think the Jenkins build job hangs...

@rubenporras
Copy link
Contributor

How would you like to use the API? Are you going to have react to a "saved" event?

Will the format operation not leave the editor dirty? Would the operation save the buffer as well after applying format to avoid that?

How do you plan to deal with concurrent edits that could happen after the user saves but before the format request is processed?

I the reason I am asking is to make your aware of these problems. My reason for using willSaveWaitUntil was to avoid these problems.

@ghentschke
Copy link
Contributor Author

How would you like to use the API? Are you going to have react to a "saved" event?

Yes. I'am using the org.eclipse.ui.editors.documentProviders extension point for a LspDoucmentProvider who extends the TextFileDocumentProvider and overwrite the createSaveOperation method.

Will the format operation not leave the editor dirty?

No.

Would the operation save the buffer as well after applying format to avoid that?

Yes., the buffer will be saved after applying the format changes (if this is enabled)

How do you plan to deal with concurrent edits that could happen after the user saves but before the format request is processed?

Thank you. This is an open issue. I assume the time window for the changes is very small, since there is a 1s timeout for the server to process. My implementation is similar to the existing format-on-save in the old C/C++ Editor in cdt. Except that the TextEdit's comes from the LSP server now.

Please check my WIP PR #178 on cdt-lsp for format-on-save

@ghentschke
Copy link
Contributor Author

replaced by #783

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support LSP based source code formatting on file save
2 participants