Skip to content

Indentation of a block nested in a function call chain #420

Open
@Fuco1

Description

@Fuco1

This is maybe not so much an issue or a bug report as a request for help. Currently when we nest function calls and then put a block inside, for example an anonymous function it indents it "that many times" as there are function calls.

I also present some other modes and how they handle it so it might be worth to behave similarly.

<?php

function() {
    foo(bar(function () {
                return 1;
            }));

    foo(bar(fux(function () {
                    return 2;
                })));
}

What I would like to have is something like

<?php

function() {
    foo(bar(function () {
        return 1;
    }));

    foo(bar(fux(function () {
        return 2;
    })));
}

This is also "compatible" with how js2-mode works

function foo() {
    foo(bar(function () {
        return 1;
    }));

    foo(bar(fux(function () {
        return 2;
    })));
}

java-mode works similarly but always indents "one step" further

class Test
{
    string foo() {
        foo(bar(new Interface () {
                return 1;
            }));

        foo(bar(fux(new Interface () {
                return 2;
            })));
    }
}

I think being consistent and not depending on the depth is a more natural way to handle the indentation even by default.

Edit: seems to be related to #251

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions