vysker / vscode-php-formatter

Visual Studio Code extension. A wrapper for the Sensiolabs PHP CS Fixer. Analyzes some PHP source code and tries to fix coding standards issues (PSR-1 and PSR-2 compatible).
MIT License
93 stars 11 forks source link

onSave configuration collapses all split editor panes when saving a file #1

Closed rjv closed 8 years ago

rjv commented 8 years ago

With the onSave configuration enabled, when I save a file that is open within a split editor, it collapses all of the editors and I lose my pane layout.

Visual Studio Code 1.3.0 Windows 10 Pro (1511) PHP CS Fixer 1.10.2 (installed with Composer)

vscode

vysker commented 8 years ago

Thank you for taking the time to post this. I have noticed this before, and I know what causes it. Unfortunately I haven't worked out a solution just yet.

What happens here is, when the file is saved, the PHP-CS-Fixer executable is run using a separate process. That means that the file is altered outside of VSCode. Therefore, the VSCode file buffer remains unchanged. It would be inconvenient, however, to have the user reopen the file on every save. So that's why the extension does that for you. The side effect of that is, however, the issue you present here. The other issue is that you lose your undo history.

I have been working on workarounds. One of which is a proposed feature for the PHP-CS-Fixer that enables it to fix a file and return the results in the command-line itself, without writing it to the file. But I have not found the time yet to test it and make a pull request.

vysker commented 8 years ago

I finally got around to fix the problems I described above.

Just now I released version 0.1.0 which uses temporary files to run the formatter on. Using this method, the undo history will no longer be lost after formatting and split views will no longer close either.