GNU bug report logs -
#16811
24.3.50; [ruby-mode] Implicit hash indentation bug
Previous Next
Reported by: Bozhidar Batsov <bozhidar <at> batsov.com>
Date: Wed, 19 Feb 2014 17:46:01 UTC
Severity: minor
Found in version 24.3.50
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
Full log
Message #16 received at 16811-done <at> debbugs.gnu.org (full text, mbox):
On 20.02.2014 16:11, Stefan Monnier wrote:
>> The problem seems to be that (let (smie--parent) (smie-indent--parent))
>
> Which does little more than (smie-backward-sexp 'halfsexp) in this case.
Yes.
>> called between "=>" and "{" doesn't stop at "=>", but goes straight to
>> the parent "{".
>
> Which seems correct.
Maybe according to the current grammar. But not if we want expressions
after `=>' to have consistent additional indentation. Which I'm now
thinking we probably don't, since otherwise, if it works right,
{
'HashSyntax' => {
'EnforcedStyle' => 'ruby19',
'SupportedStyles' => %w(ruby19 hash_rockets)
},
would turn into
{
'HashSyntax' => {
'EnforcedStyle' => 'ruby19',
'SupportedStyles' => %w(ruby19 hash_rockets)
},
and that doesn't look good. So indenting the left and right sides of
`=>' to the same level is probably the way to go.
Changed in revision 116534, fixing this bug.
Thanks for the questions!
> This said, I don't understand why
>
> {
> 'HashSyntax' => {
> 'EnforcedStyle' => 'ruby19',
> 'SupportedStyles' => %w(ruby19 hash_rockets)
> },
> 'SpaceAroundOperators' => { 'Enabled' => true }
> }
>
> is indented differently from
>
> {'HashSyntax' => {
> 'EnforcedStyle' => 'ruby19',
> 'SupportedStyles' => %w(ruby19 hash_rockets)
> },
> 'SpaceAroundOperators' => {
> 'Enabled' => true }}
>
> It seems like "it jumps back to { instead of =>" is not the full explanation.
That's because we always insert an implicit semicolon after { at eol,
and that's because it's hard to distinguish between a curly that's
opening a hash and a curly than opens a curly block.
And we need those after block-opening curlies, otherwise some token on
the first line of the block might consider the curly as its parent,
align to it, and block-opening curlies themselves align to the beginning
of the statement.
So
it("is too!") {
bar
.qux
}
turns into
it("is too!") {
bar
.qux
}
This bug report was last modified 11 years and 88 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.