Open renkun-ken opened 4 years ago
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.
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.
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'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.