#1600 deleting first line in unfolded block in Python Lexer breaks folding


I'm using version 3.4.1, the ScintillaEditBase component, compiled with Qt 5.3.

I took the Haven sample project (http://www.scintilla.org/Haven.zip) and modified it to use the Python lexer SCLEX_PYTHON. I commented out the line allowing user access to virtual space. I added the necessary code to catch the notification of the folding.

if (pscn->nmhdr.code == SCN_MARGINCLICK && pscn->margin == 2)
const int position = pscn->position;
const int line_number = Call(SCI_LINEFROMPOSITION, position, 0);
Call(SCI_TOGGLEFOLD, line_number, 0);

I created a short python script:

print "something"

for x in range(0, 3):
print "We're on time %d" % (x)

print "something else"

FOLD the "for" line and select the folded line entirely. (Attached screenshot 1).
Now delete the line by using backspace/delete/typing any key.
The result (attached screenshot 2) is that the line above gets the folded marker (-).
Now, if you click on that marker TWICE, you'll get the folded text back on the screen as if it was never deleted. (attached screenshot 3).


3 Attachments


  • Frankie Simon

    Frankie Simon - 2014-05-21

    Sorry that I didn't manage to properly format the code section in the ticket, there is a <tab> for the line inside the "for" loop.

  • Colomban Wendling

    In your step 2 (delete selection), you only deleted line 3, not line 4. So it's normal it's still there.
    To remove the content of the fold you need to select over it, like e.g. from start of line 3 to start of line 5, and then remove/replace.

    I guess this is at best a feature request, but I think if you want to remove the folded content when removing the fold header you should rather do this at the application level.

  • Frankie Simon

    Frankie Simon - 2014-05-21

    With all due respect, I disagree. If you select an entire line of a folded block and removed it, the expectation is that the whole block would be removed.

    In the CPP lexer - folding the "method()" line and removing it would make the entire block disappear:

    // comment
    void class::method() {
    // comment

    But I see now that maybe the issue here is that these lines don't really disappear but rather go into some limbo state. (Even in the CPP lexer, though the block seems to disappear, the line numbers skip.

    If you are correct and the correct behavior is to remove only the first line, then it still seems that there is a bug in not displaying the unfolded block's lines.

  • Eric Promislow

    Eric Promislow - 2014-05-21

    Frankie, if you turn on visible line-ends, you'll see that you aren't selecting
    the header line's EOF, so you're only deleting all the contents of that line from
    the first column through, but not including, the EOF. So you're left with an empty
    line, followed by the child's lines.

    Now select the entire line. Press shift-right-arrow to include the trailing EOF.
    Delete. The whole block should be gone.

    Same thing in your C++ example.

    It's not a bug.

  • Frankie Simon

    Frankie Simon - 2014-05-21

    Thank you for your comments Eric and Colomban,

    Turning on the EOL does indeed demonstrate that the end-of-line does not get selected. But there's still a problem with the previously-folded lines just disappearing.

    Try the Python example with only some empty lines preceding the for loop. In this case, similar to the C++ sample, the lines which are simply gone and there's no way to get them back without typing in anything new that could be considered as opening a new block. That definitely does not seem like by-design behavior.

  • Colomban Wendling

    Indeed the behavior you see is not good (lines being folded without a header). However, at step 3 (when the header is removed) the folding is automatically expanded both in SciTE and Geany (both using GTK), displaying the folded lines. Maybe there is a bug in the Qt layer, or in your application?

  • Frankie Simon

    Frankie Simon - 2014-05-21

    I took the Haven project posted by Neil and didn't modify it other than what I mentioned in the original issue description. Should I edit the issue somehow to reference the Qt layer specifically?

    • Neil Hodgson

      Neil Hodgson - 2014-05-21

      Haven is a small example and does not implement folding. You should examine SciTE for a full implementation of folding.

  • Frankie Simon

    Frankie Simon - 2014-05-23

    Thank you for that comment - I will check out the full implementation to see how it's supposed to work.

  • Neil Hodgson

    Neil Hodgson - 2014-05-28
    • labels: --> scintilla, folding
    • status: open --> closed-invalid
    • assigned_to: Neil Hodgson

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks