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

Add support for formatting changed lines only in a file

Open aszenz opened this issue 3 years ago • 3 comments

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

aszenz avatar Aug 19 '22 07:08 aszenz

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

junstyle avatar Aug 19 '22 08:08 junstyle

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

aszenz avatar Aug 19 '22 10:08 aszenz

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

junstyle avatar Aug 19 '22 12:08 junstyle