Skip to content

JavaScript if block without brackets indentation #30933

Closed

Description

  • VSCode Version: Code 1.14.1 (2648980, 2017-07-13T19:18:47.188Z)
  • OS Version: Windows_NT ia32 10.0.15063
  • Extensions: none

Steps to Reproduce:

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!

Activity

  1. added
    editor-find
    on Jul 18, 2017
  2. added
    editor-autoindent
    and removed
    editor-find
    on Jul 18, 2017
  3. added
    bug
    on Jul 19, 2017
  4. rebornix commented on Jul 19, 2017

    @rebornix
    Contributor

    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.

  5. rebornix commented on Jul 19, 2017

    @rebornix
    Contributor

    Related issues #31027

  6. changed the title [-]JavaScript code indents broken in 1.14[/-] [+]JavaScript if block without brackets indentation[/+] on Jul 19, 2017
  7. mjbvz commented on Jul 19, 2017

    @mjbvz
    Contributor

    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?

  8. rebornix commented on Jul 19, 2017

    @rebornix
    Contributor

    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.

  9. mjbvz commented on Jul 19, 2017

    @mjbvz
    Contributor

    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?

  10. simonl65 commented on Jul 20, 2017

    @simonl65

    Expected behaviour should be same as pre 1.14, please.

  11. 24 remaining items

  12. AshleyScirra commented on Aug 16, 2017

    @AshleyScirra
    Author

    Can someone re-open this issue since it is not fixed? Otherwise I will probably file it again. It's really annoying.

  13. cdaringe commented on Aug 16, 2017

    @cdaringe

    Simon (@simonl65)

    ALT + downArrow?

    yep!

    I don't get that in a javascript file either

    javascript language setting.

  14. mjbvz commented on Aug 16, 2017

    @mjbvz
    Contributor

    The original reported issue was fixed. I've opened #32653 to track to track the other case discussed in the comments

  15. ericdrobinson commented on Aug 16, 2017

    @ericdrobinson

    Matt Bierner (@mjbvz) But that isn't the case at all. Here's what the original reported issue read as:

    To reproduce, type this:

    if (cnd) <enter> {

    Expected result (pre-1.14):

    if (cnd)
    {
    

    Observed result (1.14):

    if (cnd)
       {
    

    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.

  16. added a commit that references this issue on Aug 16, 2017
    73d8c31
  17. AshleyScirra commented on Aug 17, 2017

    @AshleyScirra
    Author

    Matt Bierner (@mjbvz) - the original issue I reported does still reproduce for me in 1.15 following the same steps. It's not fixed.

  18. TheCyberRonin commented on Aug 17, 2017

    @TheCyberRonin

    It's fixed in the insider release. Be patient for it to get to the stable build. Ashley (Scirra) (@AshleyScirra)

  19. simonl65 commented on Aug 17, 2017

    @simonl65

    Yay - that fixed it! Matt Bierner (@mjbvz) Thank you.

  20. azarus commented on Aug 28, 2017

    @azarus

    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.

  21. simonl65 commented on Aug 28, 2017

    @simonl65

    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

  22. azarus commented on Aug 28, 2017

    @azarus
  23. locked and limited conversation to collaborators on Nov 17, 2017
  24. added 2 commits that reference this issue on Sep 6, 2026
    66226dc
    bfaef12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugeditor-autoindent

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions