Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Multiline call causes auto-indent error #646

Open

Description

@wbt

Description

A multiline function call causes Atom's autoindenter to perform unexpectedly, adding an extra layer to indentation from that call down.

Steps to Reproduce

  1. In Atom, create a new Javascript file.
  2. Write or paste code like the following:
if(myBoolean) {
    var result = MyObject.thisIsAVeryLongFunctionNameWithParameters(firstParam,
    secondParam, thirdParam, fourthParam, fifthParam); 
}
  1. Select All.
  2. Auto-indent.

Expected behavior:
Code formatted like this:

if(myBoolean) {
    var result = MyObject.thisIsAVeryLongFunctionNameWithParameters(firstParam,
        secondParam, thirdParam, fourthParam, fifthParam); 
}

Note that the close curly brace for the if is aligned with the if statement.

Actual behavior:

if(myBoolean) {
    var result = MyObject.thisIsAVeryLongFunctionNameWithParameters(firstParam,
        secondParam, thirdParam, fourthParam, fifthParam);
    }

Note that the close curly brace for the if is indented an extra level.
All the code which follows will also be indented an extra level, including closing function and object definitions. In a long file, the end can be pretty far over to the right compared to where it should be.

Reproduces how often:
Always, even in safe mode.

Versions

Atom : 1.23.2
Electron: 1.6.15
Chrome : 56.0.2924.87
Node : 7.4.0
Windows: 10 Pro

Additional Information

May be related to #553.

Activity

  1. rsese commented on May 21, 2019

    @rsese

    Thanks @wbt - reproduced in 1.39.0-nightly8 on macOS 10.12.6 (see the closing brace as reported but also line 2):

    js-auto-indent

  2. wbt commented on May 21, 2019

    @wbt
    Author

    @rsese Thanks for reporting the reproduction. I think the line 3 handling is reasonable and that the additional indent of the line continuation might be helpful. Line 2 should definitely be indented one level past line 1.

    Also if anybody's confused, I have four spaces per indent and @rsese has two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions