This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 117395 - bad ruby code reformatting for a block inside a parameter list
Summary: bad ruby code reformatting for a block inside a parameter list
Status: NEW
Alias: None
Product: ruby
Classification: Unclassified
Component: Editing (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@ruby
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-02 01:37 UTC by jamespb
Modified: 2011-01-28 20:10 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jamespb 2007-10-02 01:37:20 UTC
After reformatting this code:

puts(
  foo(3) do
    puts "a\n",
    "b\n"
  end
)

Seems like "b\n" should be indented one more level.

Product Version: NetBeans Ruby IDE 20071001112247 Java: 1.6.0_01; Java HotSpot(TM) Client VM 1.6.0_01-b06 System:
Windows Vista version 6.0 running on x86; Cp1252; en_US (nbrubyide) Userdir: C:\Users\James\AppData\Roaming\.nbrubyide\dev
Comment 1 Torbjorn Norbye 2007-11-05 05:01:01 UTC
I see the problem. The reason this happens is that you have a normal line continuation inside an argument list. I
specifically disabled line-continutations for that scenario because without it, a normal parenthesis list would look
line line continuations:

    // If there's a comma it's a continuation operator, but inside arrays, hashes or parentheses
    // parameter lists we should not treat it as such since we'd "double indent" the items, and
    // NOT the first item (where there's no comma, e.g. you'd have
    //  foo(
    //    firstarg,
    //      secondarg,  # indented both by ( and hanging indent ,
    //      thirdarg)

I can definitely make this logic more clever, but I can't think of something simple and low risk now hours before the
freeze, and, I don't think this is a must-fix bug for 6.0 since the scenario hasn't come up in the various large Ruby
source files (from the Ruby library and the Rails library) that I used to diff my formatter with the manually formatted
code in those files (to see where the algorithm was inadequate).

So, marking this one for the update release.