code collapse - suggestion

For technical support for all editions of CSS HTML Validator. Includes bug reports.
Post Reply
User avatar
Lou
Rank V - Professional
Rank V - Professional
Posts: 276
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

code collapse - suggestion

Post by Lou » Thu Oct 03, 2013 11:56 am

Albert, I find the code collapse feature handy when working with longer PHP scripts. Would it be possible to add the ability to collapse functions?
Lou
Say what you will about Sisyphus. He always has work.

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3412
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: code collapse - suggestion

Post by Albert Wiersch » Thu Oct 03, 2013 1:03 pm

Hi Lou,

I pulled up one of my long PHP scripts and I can code collapse (fold) PHP functions.

What are you not able to fold that you'd like to? Please let me know and I will be happy to pass it on to the editor component developers.
Image
Albert Wiersch

User avatar
Lou
Rank V - Professional
Rank V - Professional
Posts: 276
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Re: code collapse - suggestion

Post by Lou » Thu Oct 03, 2013 1:52 pm

Albert,
using the following file. I am using version 12.0300 there are handles along the left side to fold the "if" and "else" but not "function"

Code: Select all

<?php
/* this is a test file */
function do_something()
/*****
* I would like to be able to fold the
* function do_something() down to a single line
* like the if or else below.
******/
{
  if (true)
  {
    $i = 0;
    for ($j=0;$j<=10;$j++)
    {
       echo "$i is counting up";
       $i++;
    }
  }
  else
  {
     echo "do nothing";
  }
  return $i;
}
$k = do_something();
echo $k . "The end";
?>
Lou
Say what you will about Sisyphus. He always has work.

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3412
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: code collapse - suggestion

Post by Albert Wiersch » Thu Oct 03, 2013 5:48 pm

Hi Lou,

If you remove the comment after do_something() and before the function's opening left curly bracket ('{'), then does it work? Can you fold/collapse the function? The comment may be causing the issue. If so, then I can report it.
Image
Albert Wiersch

User avatar
Lou
Rank V - Professional
Rank V - Professional
Posts: 276
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Re: code collapse - suggestion

Post by Lou » Thu Oct 03, 2013 7:00 pm

Albert,
Interesting.
Yes if I put the comment inside the function (inside the brackets { /* ... */ } ) the both the function and the long comment can each be folded.

That solved my issue.

However, a long comment between the 'if' and its code block {...} does not prevent the 'if' from being folded. I also notice that comment 1 below can not be folded but comment 2 can. This inconsistency around the 'if' and 'function' may be due to the fact that the { } are optional following the 'if' but not the 'function' -- But thanks

if
/*
* comment 1
*/
{
/* comment 2
*/

}
Lou
Say what you will about Sisyphus. He always has work.

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3412
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: code collapse - suggestion

Post by Albert Wiersch » Thu Oct 03, 2013 7:36 pm

Thanks Lou. I reported this to the editor developers so if they address it then it should eventually make its way into CSE HTML Validator. :D
Image
Albert Wiersch

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3412
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: code collapse - suggestion

Post by Albert Wiersch » Thu Oct 10, 2013 9:23 am

UPDATE: I am told that the function folding issue has been fixed (but those comments cannot be folded). This should eventually make it into CSE HTML Validator, hopefully by the release of the next major version.

Code: Select all

function P()
/*
 * unfoldable comment
 */
{ ... }

if (true)
/*
 * unfoldable comment
 */
{ ... }
More here if you want more details:
http://forum.lmd.de/discussion/370/synt ... sue#Item_5
Image
Albert Wiersch

User avatar
Lou
Rank V - Professional
Rank V - Professional
Posts: 276
Joined: Fri Jul 29, 2005 5:55 pm
Location: CO
Contact:

Re: code collapse - suggestion

Post by Lou » Thu Oct 10, 2013 6:44 pm

Albert thanks for the update.
Starting a new phpBB I was reading their coding standards for comments and use of optional { }. They want coders to use { } following an if, else, while to define a block, even if it includes just a single statement. This supports the way the fold works.

The link you give above confirms what I thought I remembered about parsers. (it was a long time ago, life and coding were simpler) - I do miss "talking" directly to the hardware though.
Lou
Say what you will about Sisyphus. He always has work.

Post Reply