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

Run formatting in background process #251

Open
renkun-ken opened this issue May 12, 2020 · 2 comments
Open

Run formatting in background process #251

renkun-ken opened this issue May 12, 2020 · 2 comments

Comments

@renkun-ken
Copy link
Member

renkun-ken commented May 12, 2020

Currently, formatting runs in the master process of languageserver which is a blocking action (#141). If user enables formatOnSave or formatOnPaste, then either saving a large document or pasting a large chunk of code will block the lsp from processing other events.

As @randy3k noted,

I think Format Document should be a blocking action though to ensure user changes are not lost. There may be nothing we could do at this moment.

I'm wondering if we could create a background process to perform the formatting and if any edits are made to the document being formatted, or user choose to cancel it via Canceling a Work Done Progress as we could create a progress before that, the task process should be terminated to accept user edits.

@randy3k
Copy link
Member

randy3k commented May 12, 2020

I guess we could make it a background process. The current task manager is not powerful enough to handle this situation. Also, we are not executing the $/cancelRequest request, not sure if VSCode would send the cancel request for formatOnSave.

@lorenzwalthert
Copy link
Contributor

A note on this: Because of the cache, it could make sense to style the input in the background and throw it away only to build the cache (keep in mind that we cache output, not input). Then, when you style again in the blocking foreground process, all top-level expressions that are already compliant to the style guide (hopefully man) were cached will return almost immediately. Not sure I have the full context here, so just an idea.

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

No branches or pull requests

3 participants