<div>Hi All,</div><div><br></div>For the last several years (spare time) I've been constructing a simple cross-platform code editor called QSciTE using Qt4 version of Qscintilla2. You can find it here, in case you're interested:<div>
<br></div><div><a href="http://qscite.googlecode.com/">http://qscite.googlecode.com/</a></div><div><br></div><div>First off, thanks very much for making this library available to the public under the GPL. It has some wonderful functionality built-in.</div>
<div><br></div><div>I've been having some issues with code folding recently, which I believe to have stemmed from at least one bug in Qscintilla. I have a simple menu option to enable/disable code folding. Whenever I turn folding off, I want any lines that are currently folded to be unfolded automatically, since it doesn't make a whole lot of sense to have folded code that can't easily be unfolded. Here's my toggleFolding() function which is directly connected to the menu option:</div>
<div><br></div><div><div>void MainWindow::toggleFolding() {</div><div> QsciteEditor * doc = getCurDoc();</div><div> QsciteEditor::FoldStyle state = static_cast<QsciteEditor::FoldStyle>((!doc->folding()) * 5);</div>
<div><br></div><div> if (!state) {</div><div> // unfold all code before turning off folding</div><div> doc->foldAll(false);</div><div> }</div><div><br></div><div> doc->setFolding(state);</div><div>}</div><div>
<br></div><div>The QsciteEditor class is a child-class of Qscintilla, because I needed to expose several functions for use with QtScript, and because I needed to catch some key-presses that I needed to process specially. As you can see, foldAll() is only getting called just before the folding is about to be turned off. The documentation for foldAll() states "<span class="Apple-style-span" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 12px; ">If any lines are currently folded then they are all unfolded. Otherwise all lines are folded." Now, my implementation does not take into account the possibility that no lines were folded between the time that the folding was enabled and disabled (which I'll expand on below), meaning that if foldAll() works as documented, I should expect to see all lines get folded before the folding is disabled. However, even when I fold one or more lines and then turn off folding, I find that all lines are getting folded before folding gets disabled. This seems like it's a problem with the foldAll() implementation.</span></div>
<div><span class="Apple-style-span" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 12px; "><br></span></div><div><span class="Apple-style-span" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 12px; ">This also brings up a few questions:</span></div>
<div><span class="Apple-style-span" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 12px; ">1. Shouldn't setFolding() automatically unfold all lines that are currently folded before the FoldStyle is set to NoFoldStyle? Does anyone expect to have lines folded after they disable folding?</span></div>
<div><span class="Apple-style-span" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 12px; ">2. If the person using QsciScintilla is expected to unfold all lines that were folded before turning folding off, how can he know what lines are folded? As far as I can tell, that information is private, as are the functions/signals/slots that are responsible for changing a line's fold state.</span></div>
<div><span class="Apple-style-span" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 12px; "><br></span></div><div><span class="Apple-style-span" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 12px; ">So, I see these issues in the end:</span></div>
<div><span class="Apple-style-span" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 12px; ">1. There appears to be a bug in the QsciScintilla:foldAll(bool) function. It doesn't appear to function as documented.</span></div>
<div><span class="Apple-style-span" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 12px; ">2. In my opinion, QsciScintilla::setFolding() should either unfold everything when folding is turned off, or the appropriate member variables/functions/signals/slots should be changed from private to protected so that developers can deal with the situation without resorting to hacking on Qscintilla directly.</span></div>
<div><span class="Apple-style-span" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 12px; "><br></span></div><div><span class="Apple-style-span" style="font-family: 'Lucida Grande', Verdana, Geneva, Arial, sans-serif; font-size: 12px; ">For what it's worth, here's my development environment:</span></div>
<div><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif" size="3"><span class="Apple-style-span" style="font-size: 12px;">Arch Linux</span></font></div><div><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif" size="3"><span class="Apple-style-span" style="font-size: 12px;">KDEmod 4.4.0</span></font></div>
<div><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif" size="3"><span class="Apple-style-span" style="font-size: 12px;">Qscintilla 2.4.2</span></font></div><div><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif" size="3"><span class="Apple-style-span" style="font-size: 12px;">Qt 4.6.1</span></font></div>
<div><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div><div><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif" size="3"><span class="Apple-style-span" style="font-size: 12px;">Thanks for any insight you may have.</span></font></div>
<div><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div><div><font class="Apple-style-span" face="'Lucida Grande', Verdana, Geneva, Arial, sans-serif" size="3"><span class="Apple-style-span" style="font-size: 12px;">Jared Sutton</span></font></div>
</div>