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 262471 - Add code folding for arrays
Summary: Add code folding for arrays
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.2
Hardware: All All
: P2 normal with 2 votes (vote)
Assignee: junichi11
URL:
Keywords:
: 224042 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-06-17 16:08 UTC by kwfinken
Modified: 2017-07-30 11:26 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Large array (478.93 KB, image/jpeg)
2017-03-31 07:17 UTC, proger.su
Details
a screenshot of prototypes (20.71 KB, image/png)
2017-04-04 01:30 UTC, junichi11
Details
gif (585.50 KB, image/gif)
2017-04-07 01:36 UTC, junichi11
Details
Arrays folding (142.95 KB, image/jpeg)
2017-07-30 10:29 UTC, proger.su
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kwfinken 2016-06-17 16:08:38 UTC
When doing PHP programming for certain situations (such as Drupal), there are multitudes of long arrays.  It would be nice to be able to fold these and focus on the logic.  Ideally this should work for both long (e.g. array(...) ) and short (e.g. [...] ) array formats.
Comment 1 Tomas Mysik 2016-06-20 04:50:57 UTC
Adding Junichi to CC, he could be interested. Thanks.
Comment 2 proger.su 2017-03-31 07:17:53 UTC
Created attachment 163985 [details]
Large array
Comment 3 junichi11 2017-04-04 01:30:53 UTC
Created attachment 164013 [details]
a screenshot of prototypes

1. Leave brackets.
2. Don't leave brackets.(A template contains them. But the same brackets([]) are used.)
3. New([]) and old(array()) syntaxes use the same display.

Which do you prefer? I'm going to implement no.3.
If features can be added yet, I'll do it.(Currently, it's being confirming.)

Thanks!
Comment 4 proger.su 2017-04-05 06:29:40 UTC
From my point of view the second option would be better.
If it possible, do not move second bracket to next line.

$test2 = array(...22 lines);
Comment 5 junichi11 2017-04-05 09:37:14 UTC
(In reply to proger.su from comment #4)
> From my point of view the second option would be better.
> If it possible, do not move second bracket to next line.
> 
> $test2 = array(...22 lines);

Okey. I'll just leave "array". i.e. 
$test1 = [...n lines]; // short array syntax
$test2 = array[...22 lines]; // old array syntax

Unfortunately, only the same brackets can be used. If brackets are left, the closing bracket may not be on the same line with the opening bracket (e.g. In such a case: "]" is the beginning of a line. Perhaps, this is an API's problem).

I'm not sure this can be added to the next version yet.

Thanks.
Comment 6 proger.su 2017-04-06 06:27:26 UTC
It's perfect. Please write here when this will be add to release.
Comment 7 junichi11 2017-04-07 01:23:36 UTC
(In reply to proger.su from comment #6)
> It's perfect. Please write here when this will be add to release.

Sure.
Comment 8 junichi11 2017-04-07 01:36:16 UTC
Created attachment 164038 [details]
gif

If nested arrays are on the same line[1], we can collapse them using [Ctrl] key. [Ctrl]
 + click, [Ctrl] + [-], e.t.c.

More information: View > Code Folds

[1]e.g.
<?php
$test1 = ["test1" => ["test2" => ["test3" => "test4"]]];
Comment 9 proger.su 2017-04-07 06:27:01 UTC
Amazing
Comment 10 junichi11 2017-04-09 03:25:59 UTC
Fixed.

http://hg.netbeans.org/web-main/rev/43a2086b8a5c

Probably, it will be available in the development build tomorrow or later. (This means that it will also be available in the next stable version.)

Thanks.
Comment 11 proger.su 2017-04-09 14:44:07 UTC
I am very happy. Thank you very much!
Comment 12 junichi11 2017-04-09 16:02:59 UTC
You are welcome :)

Please try to test it if possible. Then if you find a problem, please report it as a new issue.

Thanks.
Comment 13 Quality Engineering 2017-04-10 02:54:19 UTC
Integrated into 'main-silver', will be available in build *201704100002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/43a2086b8a5c
User: Junichi Yamamoto <junichi11@netbeans.org>
Log: #262471 - Add code folding for arrays
Comment 14 junichi11 2017-04-11 01:38:26 UTC
*** Bug 224042 has been marked as a duplicate of this bug. ***
Comment 15 proger.su 2017-04-11 08:16:09 UTC
(In reply to junichi11 from comment #12)
> You are welcome :)
> 
> Please try to test it if possible. Then if you find a problem, please report
> it as a new issue.
> 
> Thanks.

Thank you! I will definitely test.
Comment 16 petronel 2017-05-18 09:01:12 UTC
I lack the same code folding for long arrays 

$a = array (
...
);

Should I use http://hg.netbeans.org/web-main/rev/43a2086b8a5c ? How ?
Comment 17 junichi11 2017-05-18 09:36:38 UTC
(In reply to petronel from comment #16)
> I lack the same code folding for long arrays 
> 
> $a = array (
> ...
> );
> 
> Should I use http://hg.netbeans.org/web-main/rev/43a2086b8a5c ? How ?

Please use a nightly build[1].

[1] http://bits.netbeans.org/download/trunk/nightly/latest/
Comment 18 proger.su 2017-07-30 10:29:34 UTC
Created attachment 164861 [details]
Arrays folding

I'm sorry. Before, there was no time to check.
Works great.
Thanks a lot!!!
Comment 19 junichi11 2017-07-30 11:26:13 UTC
No problem :)