soderlind / vscode-phpcbf

PHP Code Beautifier and Fixer for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=persoderlind.vscode-phpcbf
GNU General Public License v3.0
28 stars 10 forks source link

onSave Not working #34

Open nbordeau opened 5 years ago

nbordeau commented 5 years ago

PHP_CodeSniffer version 3.4.2 VS Code version 1.36.1

I can format the document by using Shift+Alt+F but the onSave setting is not formatting the document.

Turned on debugging and nothing is showing in the debug console. Here are my settings:

{
  "php.suggest.basic": false,
  "php.validate.enable": false,
  "php.executablePath": "C:\\wamp64\\bin\\php\\php7.0.33\\php.exe",
  "phpcs.standard": "WordPress",
  "phpcbf.standard": "WordPress",
  "phpcbf.onsave": true,
  "phpcbf.documentFormattingProvider": true,
  "phpcs.autoConfigSearch": false,
  "phpcbf.debug": true,
  "[php]": {
    "editor.formatOnSave": true
  },
  "phpcbf.executablePath": "phpcbf.bat"
}

Any ideas?

b13nxx commented 4 years ago

I had same issue as you do. The problem is formatter (phpcbf) is exceeding its timeout given by vscode's settings.

Solution is 'Just increase number like 2000 or something':

Screenshot_1

Writing down for quick copy: "editor.formatOnSaveTimeout": 2000

But I can give you better choice. Don't use this extension. Because it's not maintained for a year. Even source code at GitHub (ahead) and Vscode Marketplace (behind) is different. So applied fixes don't work neither.

"You do have to increase number anyway."

Better choice is use this extension. Much better. It just works. Also it has all cool features you can ask for. Auto finding .phpcs.xml, auto finding phpcs and phpcbf executables etc.