Author Topic: Code Folding + Brace Completion  (Read 5994 times)

Offline sorinev

  • Multiple posting newcomer
  • *
  • Posts: 61
Code Folding + Brace Completion
« on: July 29, 2013, 10:48:52 am »
I have a question regarding the behavior of code folding with brace completion. When auto brace completion is on, everything is fine, so far as I know. But if auto brace completion is off, it messes with the code folding when you type an opening brace '{'.

Here is a simple program below to just illustrate it. First, start with a normal program.



Then, do a couple of folds.



Next, type an opening brace somewhere. You'll notice that while the lines that were folded are still folded, the plus sign turns into a minus sign and the folding line across the screen disappears. So you now no longer have any indication that some lines have been folded, except for some seemingly missing code. You can also see that the brace is erroneously matched (it's matching the closing brace for main).



However, if you click on the minus signs where the folds are supposed to be, the code remains folded, but the minus turns back into a plus, and the line reappears.



I think that maybe the opening brace shouldn't immediately have a fold indicator pop up next to it upon being typed until a proper matching closing brace is also typed in. But is the current behavior intended, as just as unfortunate side effect of non auto-brace-completion? I looked at the code, and I don't know where the brace checking is happening (though maybe sdk\wxscintilla\src\scintilla\lexers\LexCPP.cxx, I notice something relating to folding and brace checking is happening at lines 1160-1161). After pressing the opening brace, in sdk\wxscintilla\src\scintilla\src\Editor.cxx, in the Editor::Paint function (starts on line 3526), the line is still present before line 3730, but by line 3738, the line is gone. I'm sure the line is getting flagged for visual removal at some point before this, since this is just where the repainting is happening, right?

I've only successfully compiled and looked at the code base for a few days now, and I've never looked at such an ultra massive project as this before, so still have no idea where I'd look to try and fix it. But that brings me to my next question, given that it's in scintilla, is this even in your guys' purview, or is this an issue for the scintilla team (and is it even an issue to begin with)? I don't see any of the "Code::Blocks Begin" and "Code::Blocks End" tags anywhere in the immediate or remote area of these lines and this function.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Code Folding + Brace Completion
« Reply #1 on: July 29, 2013, 11:11:18 am »
Just a quick test:
I can reproduce this.
In my opinion the matching brace highlighting is correct, because it's in fact the matching brace at this moment.
But the fold change is not correct.
It either should unfold all, because the matching braces have changed, or it should not touch the folded stuff at all.

Pure scite does not have this behaviour on my fedora 19 system, but it might use an older revision of scintilla.

Another thing I noticed:
one click on the minus-sign (after adding the "unmatched" brace) restores the black line and the plus-sign.