Open Dekadinious opened 2 months ago
Can I ask what your output looks like when you run phpcs in the terminal against your file?
phpcs plugin-file.php
Yes, it just states: "No fixable errors were found" if I ensure to have the file saved without a newline at the end and no other errors. If I add other errors, it will list and fix them, but not add the newline. So I am a bit stumped as to where it comes from when formatting through the extension and how to log that. 😅
Yeah, it is weird, because I don't see anything adding a newline in the extension code either.
I've never noticed this because I don't exclude the PSR2.Files.EndFileNewline.NoneFound rule, but I am able to replicate the issue using your phpcs.xml file, so I will keep digging.
@Dekadinious I found the problem, and opened a PR to fix it in #142
Are you able to test the PR to confirm it resolves the issue?
@jonathanbossenger That's great, and I would love that. But how do I test a specific PR? 😅
@Dekadinious, essentially you use the same steps to run the development version listed here
git clone https://github.com/valeryan/vscode-phpsab.git
cd vscode-phpsab
git checkout 138-fix-newline-error
This will open a new VS code instance running the code from that branch, which you can use to test.
@jonathanbossenger Thank you for the guidance!
I can confirm that it works, and I also tested https://github.com/valeryan/vscode-phpsab/pull/139 and can confirm that both spaces and special characters no longer trigger the error :)
I came from the wongjn extension recently, and I can't seem to get this extension to stop adding a new line at the end of my files.
I have turned "Files: Insert Final Newline" in VSCode off. I also have this in my ruleset:
When running phpcbf manually, no newlines are added and no fixes are available on the file. When I save the file and the formatter runs, a newline is added. If I disable phpcbf from this extension, no newline is added. If I run the exact phpcbf command this extension runs, no fixes are available and no newlines are added.
The only time a newline is added is if I save the file or run formatting on it, or run F1 -> PHPCBF: Fix this file.
How can I make it stop?