question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect (potentially) indentation of function arguments spanning multiple lines

See original GitHub issue

From @nomaed on October 14, 2016 10:40

  • VSCode Version: 1.6.1
  • OS Version: macOS Sierra 10.12

Steps to Reproduce:

  • Write a function (or a method) with several arguments (I did it with JavaScript and TypeScript files, but I believe any would work).
function myFunc(arg1, arg2, arg3, ...args) {
}
  • Split arguments to several lines by hitting Enter before arguments
function myFunc(arg1,
arg2,
arg3,
...args) {
}

Auto-formatting produces this result:

function myFunc(arg1,
    arg2,
    arg3,
    ...args) {
}

I would expect to see this result instead though:

function myFunc(arg1,
                arg2,
                arg3,
                ...args) {
}

Also, when manually formatting the arguments to appear in the same column (note: this is also the default/recommended setting in tslint and maybe other linters), then further lines will start with wrong indentation:

function myFunc(arg1,
                arg2,
                arg3,
                ...args) {
                    console.log('huh...');
}

vscode-multi-line-args-indent

Copied from original issue: Microsoft/vscode#13748

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:30
  • Comments:21

github_iconTop GitHub Comments

18reactions
rozzzlycommented, Oct 16, 2016

My prefered style for large method/function signatures:

class Example {
    public method(
        arg1: string,
        arg2: number,
        arg3: boolean
    ): ReturnType {
        const result = doSomething();
        return new ReturnType(result);
    }
}
6reactions
gauravmahtocommented, Jul 26, 2018

It would be best to provide a configuration so a user can choose which way to go.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PEP-8: clarify if multiline argument list with a closing `)` on a ...
When using a hanging indent the following should be considered; there should be no arguments on the first line and further indentation ...
Read more >
Automatic indentation of arguments list on multiple lines in ...
Under menu Tools → Options → Text editor → C/C++ → Formatting → Indentation → "Within parentheses, align new lines when I type...
Read more >
Function argument/parameter indentation - style - Rust Internals
For multiline function signatures, each new line should align with the first parameter. Multiple parameters per line are permitted:.
Read more >
Automatic Indentation Of Arguments List On Multiple Lines In Visual ...
Incorrect potentially indentation of function arguments spanning multiple lines #11629. Open. waderyan opened this issue on Oct 14.
Read more >
OCaml Programming Guidelines
In the case of an iterator whose argument is a complex function, ... If code is copy-pasted all over the place then the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found