Code folding and text selections

This forum should be used for all code folding problems, questions or suggestions. You can also use this forum to request folding support for a new language.
Post Reply
aphor
Posts: 21
Joined: Mon Dec 16, 2013 6:01 am

Code folding and text selections

Post by aphor » Sun Dec 22, 2013 12:07 am

I'm not sure if this should be here or under the bugs topic. Feel free to relocate this if I chose wrong...

I found a problem with my SlideIn/Out scripts that also appears to affect Add/Remove Comments. comment_range() appears to work on display line, not file line:

For example, if I have

Code: Select all

public class Bob
{
    bool SomeFunction()
    {
        return(true);
    }

    bool AnotherFunction()
    {
        return(true);
    }
}
and fold SomeFunction() so AnotherFunction begins on display line 6 like so:

Code: Select all

public class Bob
{
    bool SomeFunction()
    { ... }

    bool AnotherFunction()
    {
        return(true);
    }

}
then select the text of the entire AnotherFunction() and execute Macros->Add/Remove Comments, the resulting text is:

Code: Select all

public class Bob
{
    bool SomeFunction()
    {
        return(true);
    // }
    // 
    // bool AnotherFunction()
    // {
        return(true);
    }

}
I initially thought this was going to be related to get_marked_top() and get_marked_bottom(), but I when I put together the simplest test I could think of:

Code: Select all

function key_macro()
    message
    (
        string.format
        (
            "Selected range [%d:%d]. Current line: %d",
            get_marked_top(),
            get_marked_bottom(),
            get_line_pos()
        )
    );
end

key_macro() -- run the macro
It correctly displays the selected line numbers regardless of fold state. If I include the folded text in the selection (i.e. same fold as above, but attempt to comment out both methods), commenting works correctly.

I've run out of time to look at this today, but thought I'd post here in case you have an immediate idea where the problem is.

Thanks!

aphor
Posts: 21
Joined: Mon Dec 16, 2013 6:01 am

Post by aphor » Sun Dec 22, 2013 1:03 am

Okay, so I can't walk away from an unresolved problem...

I believe set_line_pos() is the culprit here.

Code: Select all

function key_macro()
    local lineToSet = get_marked_top()
    set_line_pos(lineToSet)

    message
    (
        string.format
        (
            "Selected range [%d:%d]. Current line: %d",
            get_marked_top(),
            get_marked_bottom(),
            get_line_pos()
        )
    );
end

key_macro() -- run the macro
run against the example folded example code with "AnotherFunction()" as the selected text will show:

Code: Select all

Selected range [8:8] Current line: 6
A simple loop around set_line_pos() to make corrections should solve my problem (that really will wait until later), but having set_line_pos() behave as expected would be even better. :)

jussij
Site Admin
Posts: 2512
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij » Sun Dec 22, 2013 1:08 am

I believe set_line_pos() is the culprit here.

That does indeed look like the problem.

Using your test file this simple macro adds the string to the wrong line !!!

Code: Select all

function key_macro()
    screen_update_disable()
    -- should add the string to this line of the test file
    -- bool AnotherFunction()
    set_line_pos(8)
    MoveLineHome()
    print("Start of line: ")
    screen_update_enable()
    screen_update()
end

key_macro() -- run the macro
I will look to get that fixed ASAP.

Thanks for submitting the bug report :)

Cheers Jussi

aphor
Posts: 21
Joined: Mon Dec 16, 2013 6:01 am

Post by aphor » Sun Dec 22, 2013 7:50 am

Thanks!

jussij
Site Admin
Posts: 2512
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij » Sun Dec 29, 2013 1:10 pm

This folding issue should be fixed in the beta version found here: http://www.zeusedit.com/z300/ze397r-beta.zip

To use the files in this zip file just make a backup copy of the Zeus install folder and replace the files contained in that folder with the ones in the zip file.

Cheers Jussi

aphor
Posts: 21
Joined: Mon Dec 16, 2013 6:01 am

Post by aphor » Thu Jan 02, 2014 9:46 pm

Your test macro

Code: Select all

function key_macro() 
    screen_update_disable() 
    -- should add the string to this line of the test file 
    -- bool AnotherFunction() 
    set_line_pos(8) 
    MoveLineHome() 
    print("Start of line: ") 
    screen_update_enable() 
    screen_update() 
end 

key_macro() -- run the macro
works correctly with the change, but "Add/Remove Comments" and my Slide In/Out scripts still behave incorrectly. (Same behavior as decsribed above).

A bit of investigation makes me believe the problem is either in comment_range() or comment_line() [if I just call "print" in my script, it works as expected], but I don't see an obvious cause. I'll look at it more tonight.

Thanks!

jussij
Site Admin
Posts: 2512
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij » Fri Jan 03, 2014 12:34 pm

Thanks for the feedback :)

The problem was with the set_cursor_pos macro function in that just like the set_line_pos macro function it was not accounting for handling the folded lines.

The new beta version from the link below should fix this issue: http://www.zeusedit.com/z300/ze397r-beta.zip

Cheers Jussi

aphor
Posts: 21
Joined: Mon Dec 16, 2013 6:01 am

Post by aphor » Fri Jan 03, 2014 8:36 pm

Confirmed fixed. Thanks!

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 4 guests