Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrow function indenting curly braces when starting next line #216737

Closed
djoodew opened this issue Jun 20, 2024 · 9 comments
Closed

Arrow function indenting curly braces when starting next line #216737

djoodew opened this issue Jun 20, 2024 · 9 comments
Assignees

Comments

@djoodew
Copy link

djoodew commented Jun 20, 2024

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.90.2
  • OS Version: Mac OS Sonoma 14.3

Steps to Reproduce:

  1. In Javascript/Typescript, create an arrow function. Curly braces should start on the following line, instead of on the same line as the function definition.
Screen.Recording.2024-06-20.at.10.01.28.AM.mov
  1. The curly braces are indented an extra level.
@vscodenpa
Copy link

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.90.2. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@djoodew
Copy link
Author

djoodew commented Jun 20, 2024

Hi, yes the issue still remains now that I'm on the latest version

@KyleKolander
Copy link

This is happening for me in TypeScript files after if conditions, too.

@rebornix rebornix assigned aiday-mar and unassigned rebornix Jun 24, 2024
@aiday-mar
Copy link
Contributor

Hi thank you for posting this issue @djoodew . So from what I understood, you mean the issue is that the next line should not be indented after an arrow of an arrow function?

So a fix has been merged recently to outdent the next line if an opening curly brace is type. The fix is in the latest Insiders release and should be in the next stable release. The new behavior would be as follows:

Screen.Recording.2024-06-25.at.09.24.13.mov

Hi @KyleKolander thank you for the comment. I suppose you are talking about braceless if statements. This change came from the issue #43244 which amassed 44 votes. As in the case above, the next line is outdent is an opening curly brace is typed:

Screen.Recording.2024-06-25.at.09.26.24.mov

@KyleKolander
Copy link

I am, and I left a comment there. This is terrible. You guys need to fix this. People expect the standard behavior. Very confusing and frustrating. I'm shocked...

@aiday-mar
Copy link
Contributor

aiday-mar commented Jun 25, 2024

The behavior we have introduced is the same as in certain other editors. As I mentioned when you type an opening curly brace the line is now outdented, so you end up with the following sequence of code:

if() 

Press Enter ->

if()
...

Type { ->

if()
{}

Press Enter from within {} ->

if()
{
....
}

What indentation behavior would you expect?

@KyleKolander
Copy link

I expect that the curly braces will be aligned with the start of the if.

// bad - how it works now
if ()
    {
        ...
    }

// good - how it always used to work
if ()
{
    ....
}

This is how it works now, which is not how it used to work.

vscode_outdent_wrong

image

Even started it with all extensions disabled code --disable-extensions.

@aiday-mar
Copy link
Contributor

aiday-mar commented Jun 25, 2024

Hi @KyleKolander yes like I said previously in my message in the other thread which you commented on, you do not see the fix and the correct behavior yet because you are on the latest stable VS Code release, and the fix is not there yet. To see the fix you have to wait until the next stable release which should come out this week or next week. You can also see the fix already now in the Insiders VS Code release which comes out every single day and can be downloaded here: https://code.visualstudio.com/insiders/.

@aiday-mar
Copy link
Contributor

Hi I believe this issue is fixed. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants