I'm feeling really frustrated right now. I have code-folding enabled, and I have most of my functions folded, but Geany is constantly un-folding functions all on its own.
This is really irritating. I want to fold all but the 1 or 2 functions I'm working on at the moment. I do this so I don't waste a lot of time scrolling or scanning the code. So I fold most functions, but every once in a while, for no apparent reason, Geany decides to unfold everything and I have to start over.
I am just about ready to throw my computer out the window. Can anyone tell me a way to make folding work correctly and have folded stuff *stay* folded while I work?
Thanks.
Daniel.
On 4 August 2010 04:15, Daniel Carrera dcarrera@gmail.com wrote:
I'm feeling really frustrated right now. I have code-folding enabled, and I have most of my functions folded, but Geany is constantly un-folding functions all on its own.
This is really irritating. I want to fold all but the 1 or 2 functions I'm working on at the moment. I do this so I don't waste a lot of time scrolling or scanning the code. So I fold most functions, but every once in a while, for no apparent reason, Geany decides to unfold everything and I have to start over.
I am just about ready to throw my computer out the window. Can anyone tell me a way to make folding work correctly and have folded stuff *stay* folded while I work?
Can you please provide more information to help repeat the bug, It doesn't happen for me. Version of Geany, which language are you editing and steps to a repeatable example would be good.
Cheers Lex
Thanks.
Daniel.
Intolerant people should be shot. _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
On Wed, Aug 4, 2010 at 2:53 AM, Lex Trotman elextr@gmail.com wrote:
Can you please provide more information to help repeat the bug, It doesn't happen for me. Version of Geany, which language are you editing and steps to a repeatable example would be good.
Geany version 0.18 running on Ubuntu 10.04 Lucid, language is Perl.
I *JUST* figured out how to reproduce the problem. Up until 5 minutes ago it looked random, but after additional testing, I found the cause:
1. Write a bunch of functions and fold them. 2. Somewhere above those functions, type a quotation mark: "
You know that when you first type a quotation mark, the highlighting is wrong until you close the quotation mark. Geany interprets that the rest of the file is in quotes. The *PROBLEM* is that when this happens, Geany decides to unfold everything, and when you close the quote, Geany doesn't fold them back. In other words, Geany ruins my folding every time I type a quoted string. :-(
I know about the auto-close-quote feature. I don't like it. I had it for a while and I decided it was more annoying than useful. For example, if I want to put quotes around an existing text, the auto-quote feature actually gets in the way.
Daniel.
On 4 August 2010 17:37, Daniel Carrera dcarrera@gmail.com wrote:
On Wed, Aug 4, 2010 at 2:53 AM, Lex Trotman elextr@gmail.com wrote:
Can you please provide more information to help repeat the bug, It doesn't happen for me. Version of Geany, which language are you editing and steps to a repeatable example would be good.
Geany version 0.18 running on Ubuntu 10.04 Lucid, language is Perl.
I *JUST* figured out how to reproduce the problem. Up until 5 minutes ago it looked random, but after additional testing, I found the cause:
- Write a bunch of functions and fold them.
- Somewhere above those functions, type a quotation mark: "
You know that when you first type a quotation mark, the highlighting is wrong until you close the quotation mark. Geany interprets that the rest of the file is in quotes. The *PROBLEM* is that when this happens, Geany decides to unfold everything, and when you close the quote, Geany doesn't fold them back.
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
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.
In other words, Geany ruins my
folding every time I type a quoted string. :-(
I know about the auto-close-quote feature. I don't like it. I had it for a while and I decided it was more annoying than useful. For example, if I want to put quotes around an existing text, the auto-quote feature actually gets in the way.
Shhh, I mostly agree with you about that, but thats just our opinion :-)
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.
Cheers Lex
Daniel.
Intolerant people should be shot. _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
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.
Daniel Carrera wrote:
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.
In C and C++ (and probably Java) you can do:
char * mult_line = "the first line\n" "second line\n" "third " "line!" ;
Cheers, Erik
On Wed, Aug 4, 2010 at 1:28 PM, Erik de Castro Lopo mle+tools@mega-nerd.com wrote:
In C and C++ (and probably Java) you can do:
char * mult_line = "the first line\n" "second line\n" "third " "line!" ;
Really? Looking at that, it feels... wrong. In Perl, PHP, Python, JavaScript, Ruby and Lua you would have to add something to concatenate these strings together.
On 4 August 2010 22:22, Daniel Carrera dcarrera@gmail.com wrote:
On Wed, Aug 4, 2010 at 1:28 PM, Erik de Castro Lopo mle+tools@mega-nerd.com wrote:
In C and C++ (and probably Java) you can do:
char * mult_line = "the first line\n" "second line\n" "third " "line!" ;
Really? Looking at that, it feels... wrong. In Perl, PHP, Python, JavaScript, Ruby and Lua you would have to add something to concatenate these strings together.
No Erik is right, strings separated by whitespace only, are catenated at COMPILE time. Catenating strings at runtime does need an operator.
Cheers Lex
-- Intolerant people should be shot. _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
On Wed, Aug 4, 2010 at 8:22 AM, Daniel Carrera dcarrera@gmail.com wrote:
On Wed, Aug 4, 2010 at 1:28 PM, Erik de Castro Lopo mle+tools@mega-nerd.com wrote:
In C and C++ (and probably Java) you can do:
char * mult_line = "the first line\n" "second line\n" "third " "line!" ;
Really? Looking at that, it feels... wrong. In Perl, PHP, Python, JavaScript, Ruby and Lua you would have to add something to concatenate these strings together.
As someone pointed out elsewhere in this thread, literal strings are concatenated at compile time in several languages (generation of byte-code for interpreted languages). However, this part of the discussion is rather off the point, because the example above isn't what causes the folding problem. It's when a single literal string spans multiple lines in the source code, not when multiple lines of source each have a literal string.
I agree with the others who say the problem should be tackled by improving Scintilla.
John
On Wed, Aug 4, 2010 at 12:32, Daniel Carrera dcarrera@gmail.com wrote:
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?
I'm not very familiar with perl but I expect you can write something like this:
$foo = "abc def ghi"
which is a string containing line breaks after "c" and "f".The same is possible with python's '''.
Then the new/old thing means this - when you type ", the rest of the file becomes a string (well, until it finds the next ") - there is no way for the lexer to know that you really don't want to create a string containing the code you have in your file after the ". Folds don't exist inside strings so the fold you have created (and all the fold points) disappears.
Personally I have no idea how to solve this problem. One way would be not to display the text after " as string until you type the second " but I think many people would be dissatisfied with this behaivor too. Anyway, the problem should be discussed at scintilla mailing list - I have tested it with SciTE and the same problem exists there as well so I seriously doubt it is geany-specific. Or is there some knob in scintilla to make this optional?
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.
In C/C++ you can write either
a = "foo" "bar";
or
a = "foo\ bar";
In both cases the preprocessor just concatenates the parts of the string. The "" just extends the string by one line so there cannot happen anything like what you experience.
Cheers,
Jiri
On 4 August 2010 23:09, Jiří Techet techet@gmail.com wrote:
On Wed, Aug 4, 2010 at 12:32, Daniel Carrera dcarrera@gmail.com wrote:
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?
I'm not very familiar with perl but I expect you can write something like this:
$foo = "abc def ghi"
which is a string containing line breaks after "c" and "f".The same is possible with python's '''.
Then the new/old thing means this - when you type ", the rest of the file becomes a string (well, until it finds the next ") - there is no way for the lexer to know that you really don't want to create a string containing the code you have in your file after the ". Folds don't exist inside strings so the fold you have created (and all the fold points) disappears.
Personally I have no idea how to solve this problem. One way would be not to display the text after " as string until you type the second " but I think many people would be dissatisfied with this behaivor too. Anyway, the problem should be discussed at scintilla mailing list - I have tested it with SciTE and the same problem exists there as well so I seriously doubt it is geany-specific. Or is there some knob in scintilla to make this optional?
Thanks for trying Scite, I don't have it installed, yes, folding is determined by the Scintilla lexers.
Cheers Lex
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.
In C/C++ you can write either
a = "foo" "bar";
or
a = "foo\ bar";
In both cases the preprocessor just concatenates the parts of the string. The "" just extends the string by one line so there cannot happen anything like what you experience.
Cheers,
Jiri _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
On 4 August 2010 20:32, Daniel Carrera dcarrera@gmail.com wrote:
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?
Hi Daniel,
Sorry if I confused you.
let me try an example, of a simple piece of Perl, with the folds shown as best I can in plain text
+- if( $a<10 ){ | print $i -- }
+- sub aaa { | return 1 -- }
Then you fold up the sub aaa.
Now deciding to add some text to the print type a quote on that line, the sub stays rolled up but notice that it changes colour to indicate its part of the string and the fold indicators disappear, as they should, it is parsed as part of a string. So there is no fold point here to store the information that this is folded.
You finish adding your string to the print statement and type closing quotes. So the sub aaa is now parsed as a sub again and so it gets its fold markers back, but as noted above the information that it was folded has been lost while it was a string.
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.
And folds in PHP and Ruby behave the same as Perl, they unfold, in fact using the same scenario as above they unfold immediately you type the opening quote, the others I don't know enough to test.
It is news to me that you can't
have a multi-line string in Java/C/C++. That sounds strange.
Dunno Java, you can't have unescaped embedded eol in C/C++ strings, you include it with the \n escape.
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.
Geany doesn't actually control the parsing, its done by Scintilla the editing component it uses. So Geany doesn't actually know that there is an unclosed string in the file, and so wouldn't be able to use this approach as far as I can see.
Cheers Lex
Cheers, Daniel. -- Intolerant people should be shot. _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
Hi Lex,
On Wed, Aug 4, 2010 at 3:11 PM, Lex Trotman elextr@gmail.com wrote:
let me try an example, of a simple piece of Perl, with the folds shown as best I can in plain text
+- if( $a<10 ){ | print $i -- }
+- sub aaa { | return 1 -- }
Then you fold up the sub aaa.
Now deciding to add some text to the print type a quote on that line, the sub stays rolled up but notice that it changes colour to indicate its part of the string and the fold indicators disappear, as they should, it is parsed as part of a string. So there is no fold point here to store the information that this is folded.
On my computer it doesn't stay rolled up. But no matter - we agree that in the end the sub is unfolded.
And folds in PHP and Ruby behave the same as Perl, they unfold, in fact using the same scenario as above they unfold immediately you type the opening quote, the others I don't know enough to test.
So that's 4 to 6 languages that have this problem.
Geany doesn't actually control the parsing, its done by Scintilla the editing component it uses. So Geany doesn't actually know that there is an unclosed string in the file, and so wouldn't be able to use this approach as far as I can see.
Not much chance of it getting fixed then?
Daniel.
On 4 August 2010 23:33, Daniel Carrera dcarrera@gmail.com wrote:
Hi Lex,
On Wed, Aug 4, 2010 at 3:11 PM, Lex Trotman elextr@gmail.com wrote:
let me try an example, of a simple piece of Perl, with the folds shown as best I can in plain text
+- if( $a<10 ){ | print $i -- }
+- sub aaa { | return 1 -- }
Then you fold up the sub aaa.
Now deciding to add some text to the print type a quote on that line, the sub stays rolled up but notice that it changes colour to indicate its part of the string and the fold indicators disappear, as they should, it is parsed as part of a string. So there is no fold point here to store the information that this is folded.
On my computer it doesn't stay rolled up. But no matter - we agree that in the end the sub is unfolded.
And folds in PHP and Ruby behave the same as Perl, they unfold, in fact using the same scenario as above they unfold immediately you type the opening quote, the others I don't know enough to test.
So that's 4 to 6 languages that have this problem.
Geany doesn't actually control the parsing, its done by Scintilla the editing component it uses. So Geany doesn't actually know that there is an unclosed string in the file, and so wouldn't be able to use this approach as far as I can see.
Not much chance of it getting fixed then?
Well, you should bring up the issue on the Scintilla mailing list, but I wouldn't be too hopeful since technically the parser is doing the right thing parsing everything as a string and so losing the folds.
Note that the same thing happens with multiline comments in C/C++, when you open the comment everything after loses the fold points and is unfolded. At least until a close comment is encountered.
Cheers Lex
Daniel.
Intolerant people should be shot. _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
I've started a thread on the scintilla mailing list.
http://groups.google.com/group/scintilla-interest/browse_thread/thread/2f0f3...
Daniel.
On 08/04/2010 03:33 PM, Daniel Carrera wrote:
Not much chance of it getting fixed then?
As a workaround, you could define in snippets.conf
a="%cursor%"
and then type a-TAB to get fold-preserving quotes.
But maybe this discussion somehow leads back to the idea of saving/loading folding status at file close/open, which I still would be much fond of.
Best, Paul