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

Multiline call causes auto-indent error #646

Open
wbt opened this issue May 20, 2019 · 2 comments
Open

Multiline call causes auto-indent error #646

wbt opened this issue May 20, 2019 · 2 comments

Comments

@wbt
Copy link

wbt commented May 20, 2019

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.

@rsese
Copy link

rsese commented May 21, 2019

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

@wbt
Copy link
Author

wbt commented May 21, 2019

@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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants