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

Fails to format when "editor.formatOnSaveMode": "modifications" is set #1677

Closed
elektronik2k5 opened this issue Dec 2, 2020 · 4 comments Β· Fixed by #2447
Closed

Fails to format when "editor.formatOnSaveMode": "modifications" is set #1677

elektronik2k5 opened this issue Dec 2, 2020 · 4 comments Β· Fixed by #2447
Labels
enhancement locked Please open a new issue and fill out the template instead of commenting.

Comments

@elektronik2k5
Copy link

elektronik2k5 commented Dec 2, 2020

Hello and thanks for releasing and maintaining this wonderful extension! πŸ™‡β€β™‚οΈ

Summary

Extension fails to format .component.html files when VSCode's "editor.formatOnSaveMode": "modifications" is set.

Steps To Reproduce:

  1. Set "editor.formatOnSaveMode": "modifications" in VSCode settings
  2. Try to format using extension (on save or via command)

Expected result

path/to/file.component.html file should be formatted.

Actual result

Status bar shows Extension 'Prettier - Code Formatter' cannot format file path/to/file.component.html and file isn't formatted.

Additional information

Unsetting "editor.formatOnSaveMode": "modifications" in VSCode settings fixes the issue. I suspect that the interop between VSCode's edited ranges and prettier's range is broken. The extension should either implement it or state and fail explicitly if this feature isn't supported.

VS Code Version:

Version: 1.51.1
Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f
Date: 2020-11-10T23:31:29.624Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Linux x64 5.9.8-200.fc33.x86_64

Prettier Extension Version:
v5.8.0

OS and version:
Fedora Linux hp 5.9.8-200.fc33.x86_64 #1 SMP Tue Nov 10 21:58:19 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Prettier Log Output

This is strange, cause the output doesn't show an error. Perhaps it is incorrect?

["INFO" - 20:50:53] Using config file at '/[redacted path]/.prettierrc.yaml'
["INFO" - 20:50:53] Prettier Options:
{
  "filepath": "/[redacted path]/src/[redacted path]/file.component.html",
  "parser": "angular",
  "useTabs": false,
  "tabWidth": 2,
  "printWidth": 120,
  "semi": true,
  "singleQuote": true,
  "quoteProps": "as-needed",
  "jsxSingleQuote": false,
  "trailingComma": "all",
  "bracketSpacing": true,
  "jsxBracketSameLine": false,
  "arrowParens": "always",
  "endOfLine": "lf",
  "embeddedLanguageFormatting": "auto"
}
["INFO" - 20:50:53] Formatting completed in 357.514512ms.
@ntotten
Copy link
Member

ntotten commented Dec 9, 2020

We don't and probably won't (due to how prettier works) support this formatting mode. I'll look to see if we can show a better error.

@elektronik2k5
Copy link
Author

Thank you. Do you mind elaborating (or referring to) the reason why they're incompatible?

@ntotten ntotten modified the milestones: v6.0.0, Version 3.0 Mar 5, 2021
@ntotten ntotten added help-wanted Not something we plan on doing, but we will take a pull request. and removed help-wanted Not something we plan on doing, but we will take a pull request. labels Apr 5, 2021
@ntotten
Copy link
Member

ntotten commented Apr 5, 2021

Duplicate of #1562

@ntotten ntotten marked this as a duplicate of #1562 Apr 5, 2021
@ntotten ntotten closed this as completed Apr 5, 2021
@github-actions
Copy link

github-actions bot commented Jul 5, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot added the locked Please open a new issue and fill out the template instead of commenting. label Jul 5, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement locked Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants