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

From: "Bozhidar Batsov" <[email-masked]>
Date: Wed, 01 Sep 2021 13:02:56 +0300

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 <[email-masked]> 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
>