Home Download Buy Blog Forum Support

Confused code folding

Confused code folding

Postby osx-addict on Wed Nov 14, 2012 3:46 pm

Ok.. So we've got a LOT of code that looks similar to the following pattern -- which is required for some re-use we're doing and this sort of thing really confuses Sublime's code folding system to the point where you can't fold up an entire function when it's got one or more comment sections like this where comments go to the far left edge -- Sublime assumes this indicates the start of a new function/method..

/////////////////////////////////////////////////////////////////////////////////////////
//
// Method: Initialize
//
/////////////////////////////////////////////////////////////////////////////////////////
void MyCoolClass::Initialize()
{
if (foo == Types::BAR)
{

////////////////////////// BEGIN CODE REPLACE ///////////////////
// AnOldLineOfCode();
ANewLineOfCode();
////////////////////////// END CODE REPLACE /////////////////////
... more statements...
}
... more statements...
}

So, Sublime puts a folding carat at the Initialize() method and another one as expected at the 'if'.. However, if you ask it to fold up the entire method, it will only fold up to the "BEGIN CODE REPLACE" and the rest remains unfolded. Would it be possible to have it be a bit smarter about the code content and not stop folding (in this case) until it sees the matching closing brace at the bottom? I realize we do things a bit different but this seems like a bug IMHO. Anyone else notice anything like this?
osx-addict
 
Posts: 3
Joined: Tue Nov 13, 2012 5:56 pm

Re: Confused code folding

Postby vitaLee on Wed Nov 14, 2012 4:18 pm

sublime folds at indentation levels where the marker will show up only if the indentation spans more than 1 line.
example:
sublime wont show fold icon on "if" line for either of this cases.
Code: Select all
if(true)
  a();

Code: Select all
if(true){
  a();
}

it will show fold icon on the "if" line in this case
Code: Select all
if(true){
  a();
  b();
}

and again a fold icon on "opening brace" line in this case
Code: Select all
if(true)
{
  a();
  b();
}
vitaLee
 
Posts: 150
Joined: Tue Dec 27, 2011 11:10 pm


Return to General Discussion

Who is online

Users browsing this forum: BugFix, gekko, Google [Bot], jps, Ospin, Yahoo [Bot] and 43 guests