vscode-php-cs-fixer
vscode-php-cs-fixer copied to clipboard
Extension stops fixing on save
Every now and then, vscode stops executing the php-cs-fixer on save. After a restart of vscode, it works again. When I manually run the command from the command palette ("Format Document") when the on-save does not work, the manual command sometimes works, but not always.
I've checked other issues on this repo but none of the provided solutions fix my problem.
Relevant settings in config.json
:
{
"php-cs-fixer.onsave": true,
"php-cs-fixer.executablePath": "/Users/george/.composer/vendor/bin/php-cs-fixer",
"php-cs-fixer.lastDownload": 1557398149117,
"eslint.autoFixOnSave": true,
"eslint.packageManager": "yarn",
"eslint.run": "onSave",
"php-cs-fixer.allowRisky": true,
"[php]": {
"editor.defaultFormatter": "junstyle.php-cs-fixer"
}
}
When I do a manual "Format Document" I get an error in the UI:
Command 'Format Document' resulted in an error.
.
The console also shows an error:
Also getting the same issue, no solutions yet?
Related, but no solution https://github.com/Microsoft/vscode/issues/69635
Nope, not as far as I know. I switched to https://marketplace.visualstudio.com/items?itemName=fterrag.vscode-php-cs-fixer for now
Thanks, will give it a try 👍
what's the result when run 'php-cs-fixer: fix this file' from the command palette ?
or try
"editor.formatOnSaveTimeout": 1250
see: https://github.com/junstyle/vscode-php-cs-fixer/issues/85
@junstyle it's not timing out, otherwise it would have been in the console. Nevertheless tried that out last week without result.
Running the fixer from the command line works as expected, both the built-in version and my own composer global
version.
Same issue here. It sometimes works and sometimes doesn't. For me it happens on save, running the commands Format Document
and php-cs-fixer: fix this file
.
The console shows:
[2019-06-21 11:33:07.972] [exthost] [error] [junstyle.php-cs-fixer] provider FAILED
[2019-06-21 11:33:07.972] [exthost] [error] undefined
and Developer tools shows the same as what @georgeboot showed.
My settings are:
"php-cs-fixer.onsave": true,
"php-cs-fixer.config": "/home/***/GoogleDrive/***/Backups/.vscode/.php_cs", // Removed sensitive info
"php-cs-fixer.executablePath": "${extensionPath}/php-cs-fixer.phar",
"php-cs-fixer.documentFormattingProvider": true,
"php-cs-fixer.lastDownload": 1560531700414,
"[php]": {
"editor.defaultFormatter": "junstyle.php-cs-fixer"
}
On my developer console on save I get the following that was present in OP's console:
WARN Error: listener failed
at _proxy.$participateInSave.then.e (mainThreadSaveParticipant.ts:349)
at process._tickCallback (internal/process/next_tick.js:68)
Running fix this file
works fine.
I'm getting the same error as well:
WARN Error: listener failed
at _proxy.$participateInSave.then.e (mainThreadSaveParticipant.ts:349)
at process._tickCallback (internal/process/next_tick.js:68)
It looks like, if there are no changes in the current document, we get "provider FAILED", but I don't get that message if a change is made. Example: On a function or IF statement, indent it +/- a few spaces. Format. No error. Format again. Error.
Even with this, Only the local scope of code is formatted. So in the above example, only that one function or IF statement is formatted, not the entire document.
@junstyle I recommend installing a fresh environment and testing. Your development environment may have some setting that prevents you from seeing this. When done, please provide your User and Workspace JSON so that we can see what we might be doing wrong. Thanks.
Is there any update on this issue?
This worked for me
"[php]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "junstyle.php-cs-fixer"
}