vscode-php-cs-fixer icon indicating copy to clipboard operation
vscode-php-cs-fixer copied to clipboard

Extension stops fixing on save

Open georgeboot opened this issue 5 years ago • 12 comments

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.

image

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: image

georgeboot avatar Jun 07 '19 10:06 georgeboot

Also getting the same issue, no solutions yet?

GC-Mark avatar Jun 20 '19 09:06 GC-Mark

Related, but no solution https://github.com/Microsoft/vscode/issues/69635

GC-Mark avatar Jun 20 '19 09:06 GC-Mark

Nope, not as far as I know. I switched to https://marketplace.visualstudio.com/items?itemName=fterrag.vscode-php-cs-fixer for now

georgeboot avatar Jun 20 '19 09:06 georgeboot

Thanks, will give it a try 👍

GC-Mark avatar Jun 20 '19 09:06 GC-Mark

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 avatar Jun 20 '19 09:06 junstyle

@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.

georgeboot avatar Jun 20 '19 10:06 georgeboot

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"
}

wsamoht avatar Jun 21 '19 15:06 wsamoht

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.

nikspyratos avatar Aug 21 '19 09:08 nikspyratos

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)

letr0n avatar Aug 27 '19 20:08 letr0n

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.

TonyGravagno avatar Sep 01 '19 20:09 TonyGravagno

Is there any update on this issue?

10bo avatar Oct 30 '19 10:10 10bo

This worked for me

"[php]": {
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "junstyle.php-cs-fixer"
}

wsand02 avatar Feb 04 '20 12:02 wsand02