Page 1 of 1

setting "autofresh", 0 -> not working as expected?

Posted: 30 Aug 2016 17:55
by highend
Latest beta...

Configuration | Tree and List | List | Always show folder sizes
in on

I'm sending two scripts to XY via WM_COPYDATA shortly after another

The first one is a query script to get a few infos from XY (which view, selected files, etc).
It's first line is:

Code: Select all

setting "autorefresh", 0;

The second script builds a menu and it uses this block:

Code: Select all

"_Initialize" setting "autorefresh", 0;
But foldersizes are autorefreshed a milisecond before the menu pops up...

The effect can be seen in this gif animation:
GIF.gif
Only turning "Configuration | Refresh, Icons, History | Auto-Refresh | Auto-refresh"
off helps...

Re: setting "autofresh", 0 -> not working as expected?

Posted: 30 Aug 2016 19:32
by TheQwerty
I don't have the time to explore but two initial thoughts:

1) When the first script finishes executing XY restores the state of AutoRefresh - could this be triggering the refresh? (Works as intended but not ideal for your uses.)

2) Similarly, does XY treat the conclusion of "_Initialize" as the end of the script and restore the setting then before proceeding with the rest of the script? (Possible bug.)

Re: setting "autofresh", 0 -> not working as expected?

Posted: 30 Aug 2016 19:54
by highend
Thanks, TheQwerty!

1.) Is the case, reenabling autorefresh (because the script is finished) automatically triggers a refresh...

Code: Select all

    setting "autorefresh", 0;
    status "test";
Scripts finishes, the list autorefreshes...

So a solution like storing the current state of autorefresh in a permanent variable, set it to off permanently in the first script and at the end of the second put the stored setting in place -> If autorefresh was on before it will now refresh again, same behavior

Any workaround available?

Re: setting "autofresh", 0 -> not working as expected?

Posted: 30 Aug 2016 20:13
by TheQwerty
SC Get supports Auto-Refresh (#480) so as you mentioned you can store and restore the state.

I think that's the only workaround right now.

If your scripts don't trigger a location (or tab) change you could probably get by just enabling Suspend Auto-Refresh and be lazy about restoring its state - that might even be a better option in the off chance your script doesn't complete or XY does not restore auto-refresh. However, you cannot currently determine its state and the only way to enable it is via CID/button which will both perform a toggle so that's no good.

Re: setting "autofresh", 0 -> not working as expected?

Posted: 30 Aug 2016 20:31
by highend
SC Get supports Auto-Refresh (#480) so as you mentioned you can store and restore the state.
Yeah, that's what I tried. In the moment you set it back to it's last value (that you've stored in a permanent variable) and assuming it was on before -> Autorefresh happens

The script doesn't do anything to modify the list pane and it doesn't switch (goto) anywhere so the autorefresh after it has ended is unnecessary but there doesn't seem to be a way to avoid that (atm)...

Even worse: When restoring the last autorefresh state any status "..."; command outputs are immediately overwritten through the following autorefresh...

Re: setting "autofresh", 0 -> not working as expected?

Posted: 30 Aug 2016 21:46
by TheQwerty
Manual Sorting will Suspend Auto-Refresh - but again toggle with no easy state detection.

It looks like SortByList will also quietly suspend auto-refreshing so you could try this very ugly hack:

Code: Select all

// Store the current sort order - unfortunately we cannot get secondary sorting as well.
$s = Get('Sort');

// Sort the current list by the current list.
SortByList ListPane(), '|';

// Whatever you want to do...
Status 'hello';
Echo 'modify something in the current folder to see it not refresh';

// Restore the original primary sort order.
SortBy GetToken($s, 1, ','), GetToken($s, 2, ',');
I'm not sure how to get XY out of the "SortByList" mode but restoring the original sort order seems to work.

Re: setting "autofresh", 0 -> not working as expected?

Posted: 30 Aug 2016 23:27
by highend
Very creative but way too ugly :ninja:

Thanks for your input!