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

Auto-indent issue

zombiesbyte opened this issue · comments

Type: Bug

I can't remember all of the affected places but I can reproduce this issue on an if block in php

class example
{
    public function t() {
        if(1) {
        // when I type the `}` character here it ends up formatting it like below...
if(1) {
}
    }
}

It's like it losing an understanding of tab placement and immediately pulls blocks to the hard left. Sometimes it pulls chunks of code above to the hard left too.

I'm reporting this error because it's annoyed me for so long and I just used bisect to identify that it was this extension that was causing the issue.

Extension version: 0.3.10
VS Code version: Code 1.84.2 (1a5daa3a0231a0fbba4f14db7ec463cf99d7768e, 2023-11-09T10:50:47.800Z)
OS version: Linux x64 6.2.0-36-generic snap
Modes:

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz (16 x 4199)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 2, 2, 1
Memory (System) 15.32GB (6.69GB free)
Process Argv --no-sandbox . --crash-reporter-id 7da8ca46-570b-42b7-8830-51cf1e541136
Screen Reader no
VM 0%
DESKTOP_SESSION cinnamon
XDG_CURRENT_DESKTOP X-Cinnamon
XDG_SESSION_DESKTOP cinnamon
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931cf:30280410
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263:30880072
vscaac:30438847
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
282f8724:30602487
89544117:30613380
vscrpc:30673769
showlangstatbar:30737416
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
welcomedialogc:30887144
pythonnosmt12:30797651
pythonidxpt:30866567
pythonnoceb:30805159
synctok:30869157
dsvsc013:30795093
dsvsc014:30804076
dsvsc015:30845448
pythontestfixtcf:30871695
pythonregdiag2:30871582
pyreplss2:30886141
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
dsvsc016:30886110
dsvsc017cf:30886113
dsvsc018cf:30886115
aa_t_chat:30882232

Happens in my testing too.

because it's difficult to judge the text whether is php heredoc string or not. so i didn't add the indent str to the code between braces.

if you think it's bad to you, you can disable this feature.

"php-cs-fixer.autoFixByBracket": false,

you'd better format the whole doc on saving. it's best way to use it.

because it's difficult to judge the text whether is php heredoc string or not. so i didn't add the indent str to the code between braces.

if you think it's bad to you, you can disable this feature.

"php-cs-fixer.autoFixByBracket": false,

you'd better format the whole doc on saving. it's best way to use it.

@junstyle There must be some way to check for this efficiently, doesn't it? We can't format the entire doc on save since we're working with large files of legacy code and don't want to mess up the diffs on PRs. This is how this feature behaves in practice:

Screen.Recording.2024-01-19.at.10.26.36.mov

Would you be able to point me to the code for this and maybe we can figure something out?