gcanyon / navigator

The amazing small powerful plugin for Livecode that makes you a better, faster developer.
12 stars 4 forks source link

In 7.3, Folding still broken in some circumstances #33

Open gcanyon opened 5 years ago

gcanyon commented 5 years ago

On Wed, Jan 30, 2019 at 8:01 AM Bob Sneidar wrote:

Hi Geoff.

Unfortunately this did not fix the issue. If you could tell me the actual function that does the folding (and the actual line number the folding begins at) I could do some more tracing to see if I even get there, and if not why.

gcanyon commented 5 years ago

​So weird!

Everything happens in doUpdateDisplay, in script-only stack "rev_s_revNavigator", which is a beast, but at least less of a beast than it once was.

To be clear, the following fails for you?

  1. Open Livecode.
  2. Create a new stack.
  3. Add three buttons to the stack.
  4. Group the three buttons.
  5. Open Navigator. It displays the stack, the card, the group, and the three buttons.
  6. Click in the fold bar by the group; the group should fold.

I just checked, and this worked on a Mac in LC 9.0.1, shown here: https://www.youtube.com/watch?v=xghd8mjaraE

When folding fails, are the controls properly indented? The critical lines here are:

757: if foldedIDArray[tID] 758: then put true into foldB[childIndex] 759: else put tIndentString after tIndent[childIndex]

For any group, if that boolean is true, the controls get hidden in 758; if false, they get indented in 759. Also critical to the process, but the same test, is:

804: if foldedIDArray[tID] and childControlCount > 0 then

That controls the display of the group's line itself, including the following "*** folded controls" line.

So as long as indenting is working, the question is: for a given group, what is in tID, and what values are in foldedIDArray? To work, there should be "true" in foldedIDArray[] and tID should contain the long id of the group.

You can trace through to check this -- Navigator makes this easier by holding the option key while opening the Actions menu and selecting "Debug IDE" at the bottom of the menu.

Or you can comment out this line:

2868: exit debug

Then before 757 put:

debug tID, foldedIDArray[tID],(the keys of foldedIDArray)

That code will put those items into the message box, and the values should point us toward what's going wrong.

slylabs13 commented 5 years ago

Hi Geoff. Sorry I've been overwhelmed by any number of things, but I finally got to do as you suggested. Here is what I got in the message box when debugging:

93517767373 stack "/Users/bobsneidar/Documents/Livecode/Plugins/Navigator.rev" doUpdateDisplay,757,stack "/Users/bobsneidar/Documents/Livecode/Plugins/Navigator_Behaviors/rev_s_revNavigator.livecodescript"

1: group id 1006 of card id 1002 of stack "Untitled 1"

2:

3:

93517767373 stack "/Users/bobsneidar/Documents/Livecode/Plugins/Navigator.rev" doUpdateDisplay,757,stack "/Users/bobsneidar/Documents/Livecode/Plugins/Navigator_Behaviors/rev_s_revNavigator.livecodescript"

1: group id 1006 of card id 1002 of stack "Untitled 1"

2:

3:

93517767373 stack "/Users/bobsneidar/Documents/Livecode/Plugins/Navigator.rev" doUpdateDisplay,757,stack "/Users/bobsneidar/Documents/Livecode/Plugins/Navigator_Behaviors/rev_s_revNavigator.livecodescript"

1: group id 1006 of card id 1002 of stack "Untitled 1"

2:

3:

slylabs13 commented 5 years ago

Looks like v7.0.2 was the last version where folding works for me. I have Sublime Text with a file comparison plugin. I can poke around to see what changed.

slylabs13 commented 5 years ago

OK Geoff I tried this version in LC 9.0.5 RC1 WITHOUT my hot patch for nested datagrid behaviors and it seems to work. It has something to do with that hot patch. Bummer.

The hot patch is basically this. In behaviorsdatagridbuttonbehavior.livecodescript I comment out the native _resourceStack handler and replace it with the one that allows me to nest datagrid behaviors:

-- Sly Labs! Inline Custom Behaviors /* private function _ResourceStack local theStack, theCharNo put the behavior of me into theStack if theStack is not empty then put offset(" of stack", theStack) into theCharNo delete char 1 to (theCharNo + 3) of theStack end if

return theStack end _ResourceStack */

local sResourceStack private function _ResourceStack local theStack, theCharNo

if sResourceStack is empty then put the behavior of me into theStack

  repeat
     if trueWord -1 of theStack is "revDataGridLibrary" or theStack is empty then
        exit repeat
     else
        put the behavior of theStack into theStack
     end if
  end repeat

  if theStack is not empty then
     put offset(" of stack", theStack) into theCharNo
     delete char 1 to (theCharNo + 3) of theStack
  end if
  put theStack into sResourceStack

end if

return sResourceStack end _ResourceStack

-- END Sly Labs! Inline Custom Behaviors

slylabs13 commented 5 years ago

Also verified that it does work in an UNMODIFIED LC 9.0.5 RC1 installation. It's on me to figure out why then. Thans for your help.

slylabs13 commented 5 years ago

Good news! I fixed this issue. Here is the modified code for behaviorsdatagridbuttonbehavior.livecodescript _resourceStack handler:

local sResourceStack private function _ResourceStack local theStack, theCharNo

if sResourceStack is empty then put the behavior of me into theStack

  repeat
     if trueWord -1 of theStack is "revDataGridLibrary" or \
        trueword -1 of theStack is "revNavigator" or \
        theStack is empty then
        exit repeat
     else
        put the behavior of theStack into theStack
     end if
  end repeat

  if theStack is not empty then
     put offset(" of stack", theStack) into theCharNo
     delete char 1 to (theCharNo + 3) of theStack
  end if
  put theStack into sResourceStack

end if

return sResourceStack end _ResourceStack

gcanyon commented 5 years ago

I'll take a look at this over the weekend. Thanks!

On Fri, May 24, 2019 at 12:51 AM slylabs13 notifications@github.com wrote:

Good news! I fixed this issue. Here is the modified code for behaviorsdatagridbuttonbehavior.livecodescript _resourceStack handler:

local sResourceStack private function _ResourceStack local theStack, theCharNo

if sResourceStack is empty then put the behavior of me into theStack

repeat if trueWord -1 of theStack is "revDataGridLibrary" or \ trueword -1 of theStack is "revNavigator" or \ theStack is empty then exit repeat else put the behavior of theStack into theStack end if end repeat

if theStack is not empty then put offset(" of stack", theStack) into theCharNo delete char 1 to (theCharNo + 3) of theStack end if put theStack into sResourceStack

end if

return sResourceStack end _ResourceStack

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gcanyon/navigator/issues/33?email_source=notifications&email_token=AAE3HUM3HEATLTT4NY2PEVTPW3KTPA5CNFSM4GTK7M2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWC7V5Q#issuecomment-495319798, or mute the thread https://github.com/notifications/unsubscribe-auth/AAE3HUOF4QYB54JG2S42YX3PW3KTPANCNFSM4GTK7M2A .

gcanyon commented 5 years ago

Well that's odd. I don't use any datagrids in Navigator. Any idea why Navigator would ever be in the chain you're tracing there? And why your code there would fluster Navigator? I'm at a loss, but glad you figured it out.

slylabs13 commented 5 years ago

I think it's because you are enumerating behaviors for datagrids. As you know, a datagrid is just a group that is treated a bit different in the IDE. The patch I put in was provided to me by someone on the use list. Instead of assuming that a datagrid's behavior is the behavior of the old button, it repeats through the nested behaviors until it finds the actual default behavior. This allows normal datagrids to work as expected, and also allows me to nest behaviors in such a way that I can insert a custom behavior before the default one.

Bob S

On May 26, 2019, at 06:17 , Geoff Canyon notifications@github.com wrote:

Well that's odd. I don't use any datagrids in Navigator. Any idea why Navigator would ever be in the chain you're tracing there? And why your code there would fluster Navigator? I'm at a loss, but glad you figured it out.