You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JavaScript if block without brackets indentation #30933
As of the 1.14 update, typing JS code has really annoying indentation behavior. I can't figure out why it changed and I can't find any relevant settings to try to change.
To reproduce, type this:
if (cnd)<enter>{
Expected result (pre-1.14):
if (cnd)
{
Observed result (1.14):
if (cnd)
{
This is the worst indentation style!
Reacted by Simon, Mike Williams, Jens Hausdorf, David Figatner, Eric Robinson, Adam Nickle, David St-Louis and Ronin
Matt Bierner (@mjbvz) do you think our indentNextLinePattern is a little bit unnecessary for TypeScript/JavaScript ? It seams that this pattern is bothering ppl instead of helping them out most of the time as writing brackets around blocks is more common.
I think enough libraries and developers do write single statement ifs that removing indentNextLinePattern entirely will be more annoying. Can we modify the regex to work around this?
Matt Bierner (@mjbvz) I'm thinking about taking one step back on indentOnType. Usually the only time that indentOnType kicks in and helps you out is when the content matches decreaseIndentPattern. Maybe a workaround here is only adjust the indentation when it matches decreaseIndentPattern otherwise users decide what the indent level they want.
Right now I don't know how to make the regex aware of context in this case.
Yes I think the expected behavior here would be to indent the next line only if there is no other content after the cursor. Would we be able to achieve that without indentNextLinePattern?
As explained in many subsequent comments, this is still an issue.
You happened to fix a related bug, just not the one described in this issue. Your fix gif shows that you type if (1) {} and then go back and hit enter between the if-condition and the braces. That is not the flow that the bug describes.
Reacted by Ronin, Brandon Gift and Ashley (Scirra)
Matt Bierner (@mjbvz) its still not fixed, just grabbed the latest version on a different fresh installed cmputer and this is still here. This is ridiculous.
Activity
rebornix commentedon Jul 19, 2017
Matt Bierner (@mjbvz) do you think our
indentNextLinePatternis a little bit unnecessary for TypeScript/JavaScript ? It seams that this pattern is bothering ppl instead of helping them out most of the time as writing brackets around blocks is more common.rebornix commentedon Jul 19, 2017
Related issues #31027
[-]JavaScript code indents broken in 1.14[/-][+]JavaScript if block without brackets indentation[/+]mjbvz commentedon Jul 19, 2017
I think enough libraries and developers do write single statement
ifs that removingindentNextLinePatternentirely will be more annoying. Can we modify the regex to work around this?rebornix commentedon Jul 19, 2017
Matt Bierner (@mjbvz) I'm thinking about taking one step back on
indentOnType. Usually the only time thatindentOnTypekicks in and helps you out is when the content matchesdecreaseIndentPattern. Maybe a workaround here is only adjust the indentation when it matchesdecreaseIndentPatternotherwise users decide what the indent level they want.Right now I don't know how to make the regex aware of context in this case.
mjbvz commentedon Jul 19, 2017
Yes I think the expected behavior here would be to indent the next line only if there is no other content after the cursor. Would we be able to achieve that without
indentNextLinePattern?simonl65 commentedon Jul 20, 2017
Expected behaviour should be same as pre 1.14, please.
24 remaining items
AshleyScirra commentedon Aug 16, 2017
Can someone re-open this issue since it is not fixed? Otherwise I will probably file it again. It's really annoying.
cdaringe commentedon Aug 16, 2017
Simon (@simonl65)
yep!
javascript language setting.
mjbvz commentedon Aug 16, 2017
The original reported issue was fixed. I've opened #32653 to track to track the other case discussed in the comments
ericdrobinson commentedon Aug 16, 2017
Matt Bierner (@mjbvz) But that isn't the case at all. Here's what the original reported issue read as:
As explained in many subsequent comments, this is still an issue.
You happened to fix a related bug, just not the one described in this issue. Your fix gif shows that you type
if (1) {}and then go back and hit enter between the if-condition and the braces. That is not the flow that the bug describes.Remove js indent on if/for/while block
AshleyScirra commentedon Aug 17, 2017
Matt Bierner (@mjbvz) - the original issue I reported does still reproduce for me in 1.15 following the same steps. It's not fixed.
TheCyberRonin commentedon Aug 17, 2017
It's fixed in the insider release. Be patient for it to get to the stable build. Ashley (Scirra) (@AshleyScirra)
simonl65 commentedon Aug 17, 2017
Yay - that fixed it! Matt Bierner (@mjbvz) Thank you.
azarus commentedon Aug 28, 2017
Matt Bierner (@mjbvz) its still not fixed, just grabbed the latest version on a different fresh installed cmputer and this is still here. This is ridiculous.
simonl65 commentedon Aug 28, 2017
Azarus (@azarus) I don't think the fix has made it to the release version yet. I'm guessing you're on version 1.15.x, but the fix is in 1.16.0-insider - which you can download from https://code.visualstudio.com/insiders
azarus commentedon Aug 28, 2017
Fix JS/TS indentation for if (...) | {} case
Remove js indent on if/for/while block