bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32496: 27.0.50; Strange indentation when ruby-align-chained-calls is


From: Bozhidar Batsov
Subject: bug#32496: 27.0.50; Strange indentation when ruby-align-chained-calls is t
Date: Wed, 01 Sep 2021 13:02:56 +0300
User-agent: Cyrus-JMAP/3.5.0-alpha0-1126-g6962059b07-fm-20210901.001-g6962059b

Ah, I finally understood the issue at hand! It's really hard to discuss indentation problems in e-mail. :D

Yeah, I can confirm there's a bug when using (setq ruby-align-chained-calls t) in this example:

some_variable.where.not(x: nil)
                         .where(y: 2)

The two `where`s should be lined up, but currently the second `where` is lined up with the `not`.

some_variable.where.not(x: nil)
                                    .where(y: 2)

I can also confirm that the first behavior is what RuboCop (Ruby's popular linter/formatter) expects, when configured for aligned chained method calls. 

On Wed, Sep 1, 2021, at 12:53 PM, Lars Ingebrigtsen wrote:
Bozhidar Batsov <bozhidar@batsov.com> writes:

> Sorry for the radio silence - I've been super busy lately. 
>
> It's hard for me to understand the indentation in the examples in the email
> (as it seems the same to me). Very simply put - the idea is to align multi-line
> chained calls on the `.`, as opposed to just nest them under the root receiver
> as we'd normally do.
>
> I think Dmitry implemented this great and it's behaving just as it's supposed
> to be behaving. Perhaps you misunderstood how this was supposed to
> behave? What's the indentation you expected? 

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

The examples were in HTML mail, so they were difficult to understand.

Emacs (with (setq ruby-align-chained-calls t)) currently aligns like
this:

some_variable.where
             .not(x: nil)
             .where(y: 2)

Which is correct.  However, when there's a mixture of keeping things on
one line and breaking, we get this:

some_variable.where.not(x: nil)
                   .where(y: 2)

I think the bug reporter wants:

some_variable.where.not(x: nil)
             .where(y: 2)

I.e., align multiline chained calls on the first dot, not the last?

(I don't know Ruby, so I have no opinion here.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

[Prev in Thread] Current Thread [Next in Thread]