junstyle / vscode-php-cs-fixer

PHP CS Fixer extension for VS Code

Home Page:https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

header_comment is inserted in all copy-paste and more

anibalsanchez opened this issue · comments

Hi,

I love the extension and it works wonderfully. I have a weird issue that started to happen at some point.

When I copy-paste any piece of code the header_comment is inserted before the text that I'm pasting. If I ctrl+z immediately, the header_comment is removed, but the pasted code stays.

As a workaround, I'm disabling the header_comment in the .php-cs-fixer.dist.php.

VSCode 1.64.2
PHP 7.4.16
vscode-php-cs-fixer v0.2.10

  1. The issue also affects other copy-paste actions. For instance, you paste use HasFactory; and it immediately disappears if the use Illuminate\Database\Eloquent\Factories\HasFactory; is not declared before.

  2. And, if you paste use Illuminate\Database\Eloquent\Factories\HasFactory; first, then it disappears because there is reference in the code.

  1. about: "header_comment"
    can you replay the actions, and paste your config .php-cs-fixer.dist.php

  2. maybe php-cs-fixer optimize the codes, and delete unused codes, you should change your php-cs-fixer config

if you have any problems about php-cs-fixer, maybe https://github.com/FriendsOfPHP/PHP-CS-Fixer has answer.

If I disable junstyle.php-cs-fixer as editor.defaultFormatter, and only fix manually, php-cs-fixer works perfectly.

It looks like the problem is the interaction between junstyle.php-cs-fixer and vscode. There are rules that can't be applied at every editing step.

I have the same issue.

Our best bet is probably just "editor.formatOnPaste": false.
You could also disable this just for php.

But it's not ideal...