On Wed, Aug 4, 2010 at 11:28 AM, Lex Trotman elextr@gmail.com wrote:
Ok, thats because they are NEW fold points, the old ones you had rolled up were removed when you turned the whole file into a string.
New fold points are always open otherwise as you typed the program it would fold up on you.
I don't understand at all. What is a "new" fold point vs an "old" fold point? I'm talking about functions that have been in the file for more than a day. Isn't that "old" enough? Why does Geany keep unfolding everything? Are you saying that every single function in my program is a "new" fold point? How do I make them old?
This isn't a problem with other languages, except for Python triple quotes, because AFAIK no other language embeds newlines in strings, so the extent of an opened string is limited to one line and the fold points don't disappear since they are on other lines.
PHP does too, and Ruby as well, and JavaScript, and I suspect probably Lua. So that's at least six languages. It is news to me that you can't have a multi-line string in Java/C/C++. That sounds strange.
Sadly I don't see an easy fix for the problem, what do other editors do? Maybe we can steal their algorithm if it works better.
NetBeans doesn't have this problem. I don't know what algorithm they use, but I can tell you how it behaves. Say I start with the following PHP program:
<?
function test($var) { // Do nothing. // Do nothing. // Do nothing. }
?>
Then I fold the function:
<?
+ function test($var) { ... }
?>
Then I insert a string on top. The function remains folded:
<? $string = "Hello
+ function test($var) { ... }
?>
And the only way the function is expanded is if I *close* the string, on the other side of the function:
<? $string = "Hello
function test($var) { // Do nothing. // Do nothing. // Do nothing. }
";
?>
It seems to me that NetBeans figures out that the quotes are not properly closed (proven by the fact that the file ends in an un-terminated string) and it waits until the string is closed before deciding what to do with fold points. That's my best guess at their algorithm.
Cheers, Daniel.