pretty-php icon indicating copy to clipboard operation
pretty-php copied to clipboard

It changes comment line style (from "# ..." to "// ...")

Open ozanmuyes opened this issue 9 months ago • 2 comments

I setup VSCode to "format on save" using pretty-php and when I save it changes #region Twig to // region Twig and because of this I lose collapsible regions in VSCode. I couldn't find any relative pretty-php setting, and I don't want to change editor.foldingStrategy. Thanks.

PS: // #region Twig is also not working.

ozanmuyes avatar Apr 20 '25 13:04 ozanmuyes

Thanks for reporting this.

Can you direct me towards a spec or project with this use of #-based tagging, or is this a standalone approach you're using in your own projects?

lkrms avatar Apr 25 '25 00:04 lkrms

Thanks for the reply, and sorry for my ignorance on the background; it is a standalone approach that I try to use in my personal project.

  1. Unsaved file, unfolded region Image
  1. Unsaved file, folded region Image
  1. Saved file, region has gone Image

Appendix A

Below is my .vscode/settings.json contents for the project;

{
  "editor.formatOnSave": false,
  "[php]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "lkrms.pretty-php"
  },
  "[twig]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "mblode.twig-language-2"
  }
}

PS: For JavaScript and TypeScript // #region works in VSCode but for PHP it does not.

ozanmuyes avatar Apr 26 '25 15:04 ozanmuyes

Ah, so you're using VS Code's #region markers for folding?

I didn't even know these were a thing!

It seems reasonable to me for pretty-php to ignore these when normalising comments. Will try to get an update out soon.

lkrms avatar Apr 29 '25 01:04 lkrms

It wouldn't be a problem if we were able to change those aforementioned "defined markers", yet here we are now 🤷🏻.

PS: I was using those markers without knowing about them (simple SO answer did the trick for me in the case of JS/TS back then), thank you for letting me know that they exist ☺️

ozanmuyes avatar Apr 29 '25 01:04 ozanmuyes

This has been fixed in v0.4.94, which should be available via VS Code's respective marketplaces in a few minutes :)

(Apologies for the delay due to difficult personal circumstances; I'm sure this issue has been a frustrating one for you in the meantime.)

lkrms avatar May 23 '25 04:05 lkrms

Thank you for your effort, sorry for the circumstances. Hopefully they will gone away

ozanmuyes avatar May 24 '25 23:05 ozanmuyes