-
Notifications
You must be signed in to change notification settings - Fork 44
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
Prettier fails when trying to format Apex using the ?. or ?? operators #1379
Comments
Hi, I'm not sure why you think Prettier Apex doesn't support these operators? Please make sure you're running the latest version of Prettier Apex. |
Hey @dangmai, thank you for replying. I thought Prettier didn't support ?? and ?. since that is what the error message was saying when I tried formatting using the 2.0.1 version. I have updated to the latest version (2.1.4) and tried formatting the same file which uses these operators and now I am getting a different error. ["ERROR" - 3:46:39 PM] Error formatting document. Am I missing something that needs to be configured? |
Hello, please restart VSCode, it should work afterwards. |
Thank you very much! That fixed it. Also just read #1176 which explained the same thing. Should've done that before opening an issue. Thank you once again! |
'Prettier' code formatter for Apex does not currently support ?. or ?? operators, so it will not format Apex using those operators. To bypass this, you can replace those operators and then try formatting. After formatting, you can undo-replace those operators (don't use Control + Z since it will undo the code formatting done by 'Prettier').
Sample VS Code find-replace expressions:
replace ?.
from: ?.
todo: /?./.
undo replace ?.
from: /?./.
todo: ?.
replace ??
from: ??
todo: /??/ ==
undo replace ??
from: /??/ ==
todo: ??
The text was updated successfully, but these errors were encountered: