GNU bug report logs -
#60321
29.0.60; ruby-mode indentation of hash or array as first arg in multiline method call
Previous Next
Reported by: Dmitry Gutov <dgutov <at> yandex.ru>
Date: Sun, 25 Dec 2022 21:30:02 UTC
Severity: normal
Merged with 72099
Found in versions 29.0.60, 31.0.50
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On Mon, Dec 26, 2022 at 8:16 PM Dmitry Gutov <dgutov <at> yandex.ru> wrote:
>
> Vim's choice looks saner to my eye. Probably comes down to the choice of
> indentation algorithm, though.
Agreed, though it's hard to pick which is more sane when all the
options start with insanity.
> > If I had to type it as above, I would probably indent it like this:
> >
> > and_in_a_method_call({
> > no: :difference
> > },
> > foo,
> > bar)
> >
> > But I can't imagine that would be easy to implement at all, so I
> > wouldn't bother.
>
> The indentation logic itself might be not that difficult to write, but
> the fact that the expression will have to be reindented as soon as the
> method call grows a second argument (after the user types the comma?),
> makes it a hard sell usability-wise.
Right, I think that's just more of the same thing... We are looking at
ways of writing code that are out of the realm of reason. It's a
challenge to define behavior when the behavior could very well be
undefined. But, if we must define it, then what are our guiding
principles? Not having to reindent preceding lines when adding a new
line may be a very reasonable one. In that case, the only two options
I could think of would be:
and_in_a_method_call({
no: :difference
},
foo,
bar)
or
and_in_a_method_call({
no: :difference
},
foo,
bar)
The difference being if we decide to dedent upon the last closing
indent-requiring-token or the first.
I think a reasonable rule of thumb for a human might be: "If you open
N indents on one line, you must close N indents on one line". Any time
you stray away from this, behavior becomes... not ideal.
Aaron
This bug report was last modified 319 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.