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

Not working, confusing error message with"editor.formatOnSaveMode": "modificationsIfAvailable" #860

Closed
Tracked by #879
rotu opened this issue Jun 4, 2023 · 4 comments

Comments

@rotu
Copy link
Contributor

rotu commented Jun 4, 2023

Describe the bug

I have my project set up to use Deno as a formatter, but it doesn't format on save, instead giving the error message:

"Extension 'Deno' is configured as formatter but it cannot format 'TypeScript'-files"

This error message is extra confusing since the extension can format a file with "Format Document" or "Format Document With..." commands.

  1. open a workspace under git source control
  2. add the following to workspace setup:
     "[typescript]": {
     	"editor.defaultFormatter": "denoland.vscode-deno"
     },
     "[javascript]": {
     	"editor.defaultFormatter": "denoland.vscode-deno"
     },
     "editor.formatOnSave": true,
     "editor.formatOnSaveMode": "modificationsIfAvailable"
  3. Edit and save a typescript file.

If I disable the builtin plugin vscode.git, or if I set mode="file", format on save works again.

Expected behavior

I expect one of the following in decreasing order of preference:

  1. Format the modified section of the file
  2. Format the whole file
  3. Give an explanatory message to change "editor.formatOnSaveMode"

Screenshots

image

If applicable, add screenshots to help explain your problem.

Versions

vscode: 1.78.2 deno: 1.34.1 extension: 3.19.1

@rotu rotu changed the title mode = modificationsIfAvailable Incompatible, poor error message with "editor.formatOnSaveMode": "modificationsIfAvailable" Jun 4, 2023
@rotu rotu changed the title Incompatible, poor error message with "editor.formatOnSaveMode": "modificationsIfAvailable" Not working, confusing error message with"editor.formatOnSaveMode": "modificationsIfAvailable" Jun 4, 2023
@bartlomieju
Copy link
Member

Appears related to #840, #829 and #657

@bartlomieju bartlomieju mentioned this issue Jul 11, 2023
17 tasks
@dsherret dsherret self-assigned this Jul 19, 2023
@dsherret dsherret removed their assignment Jul 19, 2023
@dsherret dsherret added wontfix This will not be worked on and removed bug Something isn't working labels Jul 19, 2023
@dsherret
Copy link
Member

I'm not sure if there's much that can be easily done here. Deno doesn't support range formatting (modifications/modificationsIfAvailable) so the vscode-languageclient sees that Deno says it doesn't support range formatting, then doesn't range format, and that message box appears. It would be nice if there were an instructional message box to remove the "editor.formatOnSaveMode": "modificationsIfAvailable", but I'm not sure if there's a way to inject that somewhere. If anyone knows a way or has some suggestion based on knowing how vscode and vscode-languageclient works, please let me know.

So unfortuantely I'm going to close this one as "wontfix". The workaround to get this to work is to remove "editor.formatOnSaveMode": "modificationsIfAvailable". The extension should be fast enough at formatting individual files that you shouldn't really need this option anyway.

@dsherret dsherret closed this as not planned Won't fix, can't repro, duplicate, stale Jul 19, 2023
@rotu
Copy link
Contributor Author

rotu commented Jul 21, 2023

@dsherret I think you're right and this is a bug upstream. Namely, the Deno language server says it supports document formatting and the integration layer vscode-languageclient should understand this since the protocol differentiates between document formatting and range formatting, but vscode is spitting out an error message that misrepresents the situation.

@Malix-Labs
Copy link

This is likely coming from VSCode, as I also have the same problem with all major Go formatter

microsoft/vscode#203463

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

No branches or pull requests

4 participants