junstyle / vscode-php-cs-fixer

PHP CS Fixer extension for VS Code
https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer
MIT License
357 stars 45 forks source link

Add support for formatting changed lines only in a file #184

Open aszenz opened 2 years ago

aszenz commented 2 years ago

VScode has this formatting feature, where it only formats changed lines of code instead of the whole file. Can we add support for this

junstyle commented 2 years ago

this extension spawn a child process to execute php code, it's inefficient and slow. if do more complex work, it will be more slower. and php-cs-fixer can't only format changed code, grammar will be wrong. if you means only replace the changed lines, i think it's not necessary, replace the whole file cost less time

aszenz commented 2 years ago

This feature is useful not for performance but rather to reduce the diff in pr's, u contribute new code, and u wish to format it only and not the whole file. Also helps in code review

junstyle commented 2 years ago

this is a extension for vscode, just a wrapper for php-cs-fixer. if you want to use in git, i think you should use php-cs-fixer directly, it provide the diff info in the result.

php-cs-fixer fix --diff --dry-run