rest[0] problem

52 views
Skip to first unread message

David Allen

unread,
Mar 23, 2018, 4:57:27 AM3/23/18
to TiddlyWiki
I have about five hundred tiddlers that all display a decently-sized image.  To reduce the impact on my machine, I've implemented a slider system that keeps track of a slider index using two simple buttons, then displays a list of five items starting at the slider index.

Filter code is as follows: "[tag[alien]!prefix[Template]sort[]rest{!!scroll_index}limit[5]]"

When the scroll_index field is supposed to start at zero and increment or decrement by five according to the button I press.

rest[0] and rest[1] have the same output.  Is this a bug or by design?

Jeremy Ruston

unread,
Mar 23, 2018, 5:41:32 AM3/23/18
to tiddl...@googlegroups.com
Hi David

The implementation of the rest filter (and most of the other “list-ops” filters) uses the default parameter value of one if the provided parameter value is zero.

The code was written that way on purpose, but I think it’s probably a bug. You may be able to work around it for the moment by having a dummy first entry in the list that you can’t scroll to?

Best wishes

Jeremy

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/72ba456a-c337-4f45-86c4-81671bf9ae3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephan Hradek

unread,
Mar 23, 2018, 5:56:18 AM3/23/18
to tiddl...@googlegroups.com
Yes, there is a bug!

var count = parseInt(operator.operand) || 1,

I think this would fix it

var count = parseInt(operator.operand),
                results
= [];

if( isNaN(count) ) {
count= 1;
}

There are more like that :(

The mistake is that any operand, not being a number, should be replaced by 1, just chopping of the first element.

Unfortunately "0" in this regards is also counted as not being a number.

I wonder what negative numbers would produce ;)


Stephan Hradek

unread,
Mar 23, 2018, 6:37:12 AM3/23/18
to TiddlyWiki


Am Freitag, 23. März 2018 10:41:32 UTC+1 schrieb Jeremy Ruston:
but I think it’s probably a bug.

It is and I just created a pull request to fix it.

I also adjusted the x-listops, I hope that's okay. They had the same piece of code in I once introduced.

https://github.com/Jermolene/TiddlyWiki5/pull/3188
Reply all
Reply to author
Forward
0 new messages