kokororin / vscode-phpfmt

Integrates phpfmt into VS Code
https://marketplace.visualstudio.com/items?itemName=kokororin.vscode-phpfmt
BSD 3-Clause "New" or "Revised" License
129 stars 29 forks source link

comments moves to beginning of the line if written above control structure #142

Open vikaskhunteta opened 8 months ago

vikaskhunteta commented 8 months ago

Hi,

Everything works fine except the comments before the control structure, see the screenshot

Screenshot 2024-04-01 192938

Other than above issue, the extension works great into VS code even for large files but doesn't work into sublime text, only very small files are formatted. For medium to large size files, it hangs the editor and I have to end the process to resume working. I don't use VS code for development purpose, so I have to switch between editors just for formatting.

driade commented 8 months ago

Hi @vikaskhunteta. I use it on my regular basis on Sublime Text, and seems fine. May you please share some of this big files with me to check if there's any infinite loop? The code behind both vscode-phpfmt and the sublime plugin it's the same (https://github.com/driade/phpfmt8).

vikaskhunteta commented 8 months ago

@driade Thanks for prompt response, the files on which the extension hangs into sublime doesn't have even 200 lines, I believe there must be some conflict with other extension installed. Here is the list of extension installed

Better Completion, Bootstrap 3 Snippets, BracketHighlighter, Brackets Color Scheme, Color Highlighter, CSS Lint, DocBlockr, DotENV, Emmet, Emmet CSS Snippets, Formatter, Git, HTML, HTML-CSS-JS Prettify, HTML5, HTMLBeautify, jQuery, JSHint, JSHint Gutter, JsPrettier, Minifier, Minify, Monokai Extended, PyV8, Rails, Sass, SCSS, SCSS Compiler, SideBarEnhancements, SideBarGit, SublimeCodeIntel, SublimeLinter, SublimeLinter-csslint, SublimeLinter-phplint, Tailwind CSS Autocomplete, WordPress

I removed PHPFMT package because of the issue mentioned earlier, I have two PHP installed, default is PHP7.4 also set Path env, but for PHPFMT I configured PHP8.2 as it was not working at all with PHP7.4 into sublime, however into VS Code it working with PHP7.4 without issue.

driade commented 7 months ago

Thanks. I'll check the comment formating issue.

vikaskhunteta commented 7 months ago

@driade Any update on this? Also did you get chance to debug the issue on Sublime Text with all packages that I have installed on my system?

driade commented 7 months ago

No chance to check it, sorry.

lutyne commented 5 months ago

me too. troubling question

lutyne commented 5 months ago

comments moves to beginning, is there any solution?

vikaskhunteta commented 5 months ago

@lutyne The only working solution I found is to use of multi line comments instead of single line comments above the if condition

lutyne commented 5 months ago

@vikaskhunteta multi comments cause another problem, the comments are not only moved to the head, but also separated...... 企业微信截图_17195650241592 企业微信截图_17195650377057

driade commented 5 months ago

Sorry, I'll try to find a solution next month

vikaskhunteta commented 5 months ago

Screenshot 2024-06-28 143043 @lutyne Multi line comments are written like this

lutyne commented 5 months ago

A matter of habit.... It seems I need to adapt.

vikaskhunteta commented 4 months ago

@driade Did you get chance to look into this? Other than issue with comments above if and foreach syntax,

if the comment is placed after the closing curly braces like below

{
    some code
} // comment

then after formatting it would go down like this

{
    some code
}

// comment

sometimes comments after the syntax like this also move to new line below the syntax

$value = functionName( [
    'Id' => $id // REQUIRED
] );