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 189958 - RFE : code foldings
Summary: RFE : code foldings
Status: NEW
Alias: None
Product: ruby
Classification: Unclassified
Component: Editing (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal with 2 votes (vote)
Assignee: issues@ruby
Depends on:
Reported: 2010-08-28 08:38 UTC by Masaki Katakai
Modified: 2016-02-09 01:54 UTC (History)
3 users (show)

See Also:
Exception Reporter:

code folding patch archive for ruby editor (1.90 MB, application/zip)
2010-10-18 08:58 UTC, masaakiaoyagi

Note You need to log in before you can comment on or make changes to this bug.
Description Masaki Katakai 2010-08-28 08:38:20 UTC
Product Version: NetBeans IDE 6.9.1 (Build 201007282301)
Java: 1.6.0_21; Java HotSpot(TM) Client VM 17.0-b17
System: Windows XP version 5.1 running on x86; MS932; en (nb)

I got the suggestion from community member in Japan. Please try the following codes
in NetBeans editor and check code holding.

=begin comment


# == Foo class
# sample class
class Foo

# === foo method
# sample method
def foo(args)


HASH = {

ARRAY.each do |i|

if cond

case cond
when true

When I tried NetBeans 6.9.1, only followings are handled properly as code holding.

=begin comment

class Foo

def foo(args)

But others are not. Is it possible to improve for other cases?
Comment 1 masaakiaoyagi 2010-10-18 08:58:16 UTC
Created attachment 102447 [details]
code folding patch archive for ruby editor

I made a patch for this issue and attached. Please review.

1. Changes
  The following types of "Collapse by Default" are added:
  - Literals
  - Control Structures

  The following folding items are added:
  - Comments (type of "Collapse by Default": Javadoc Comments)
    - Multi-line Comments
    - Embedded Documentation
  - Literals (type of "Collapse by Default": Literals)
    - Arrays
    - Hashes
    - Ranges
    - Here Document
    - Strings
    - Symbols
    - Regular Expressions
    - Command Expansion
  - Control Structures (type of "Collapse by Default": Control Structures)
    - Conditional Branches
    - Conditional Operator
    - Loops
    - Method call with block (Iterator)
    - Exception Handling

2. Specifications (Unlike Javadoc Comments)
  - Folded block show first line.
  - Single line block can't fold.

3. Known Issues
  - The following codes should NOT be collapsed but it can be collapsed.
    - Not a line comment
        # But not a line comment,
        # be recognized as a line comment.

  - The following codes should be collapsed but it can NOT be collapsed.
    - Multi-line Comments that folding length is 5 characters or less

    - Two-line embedded documentation

    - Method call with hash
      foo(:a => 1,
          :b => 2)
      foo :a => 1,
          :b => 2

    - begin ... end (while|until) ...
      end while cond
      end until cond

    - BEGIN or END block
      BEGIN {
      END {

  - The following codes are folded incorrectly.
    - Multiple conditional operator
      cond1 ? 1 : cond2 ? 2 : 3

    - Multiple here documents
      print <<FIRST, <<SECOND
        First Here Document
        Second Here Document

4. Contents of zip file
  - netbeans_new
    Modified jar files.
    Overwrite NetBeans directory.
  - netbeans_old
    Original jar files.
  - nb691_ruby_folding.diff
    Difference from NetBeans 6.9.1.
  - folding_sample.rb
    Sample ruby script.

5. Notes
  - When you overwrite jar files, it may not be reflected.
    In that case, delete ${userdir}/var/cache and restart NetBeans.
  - Use at your own risk.

Comment 2 Masaki Katakai 2010-10-18 09:47:52 UTC
Thank you very much Aoyagi-san for contributing the patch!

Can anyone review please?

He is a community member in Japan.
Comment 3 Erno Mononen 2010-10-20 07:24:51 UTC
Thanks for the patch! The changes in the Ruby modules seem fine, just please make sure they don't cause any new unit test failures (there are several tests in the ruby editing module for code foldings). The changes in options.editor, editor.settings and csl need to be reviewed by their owners, so assigning to editor for further review.
Comment 4 David Strupl 2010-10-20 08:15:45 UTC

I have reviewed the diff - it seems fine. The only remaining thing is that the following changed files


contain API change that require:

a. Note in apichanges.xml describing the addition (compatible, addition)
b. increasing the spec version of the respective modules

Passing back to ruby - feel free to apply the patch if the api changes are documented properly (both a. and b. please).

Thanks for the patch and willing to improve the editor.

Comment 5 Erno Mononen 2010-10-21 11:23:46 UTC
@masaakiaoyagi: Do you plan to provide a final patch that addresses the concerns raised here, or do you expect me or someone else to do that? Thanks.
Comment 6 masaakiaoyagi 2010-10-22 01:56:35 UTC
Thanks for reviews.

I'm sorry I don't have much time to work on it now.
Erno, could you help?
Comment 7 Masaki Katakai 2011-06-23 15:07:43 UTC
Hi team,

Any plan to integrate the patch?
Comment 8 SerafinaWeathers 2016-02-09 01:54:45 UTC
Savvy comments ! Coincidentally , if anyone need to merge PDF files , my secretary used a tool here <a href="" ></a>.