action-listops and the prepend operator odd behavior

62 views
Skip to first unread message

c pa

unread,
Sep 11, 2017, 12:12:31 PM9/11/17
to TiddlyWiki

Overview
I am testing standard tiddlywiki operators and came up with the following odd behavior:

Description
Using +[prepend[This is a test]] as a subfilter to action-listops will prepend the string twice (but not 3 times) if executed three times in a row

Code Example
Tiddler = action-listops-test4
<br/>
Field Value: {{action-listops-test4!!fieldlist}}

<$button>Set Up Test
    <$action-setfield $tiddler="action-listops-test4" $field="fieldlist" $index="" $value="one [[and a two]] [[and three]] four" />
</$button>
<$button>Execute test
    <$action-listops $tiddler="action-listops-test4" $field="fieldlist" $index="" filter="" $subfilter="+[prepend[This is a test]]" $tags="" />
</$button>

Expected behavior
Set up Test
Field Value = "one [[and a two]] [[and three]] four"
Execute Test
Field Value = "This is a test one [[and a two]] [[and three]] four"
Execute Test
Field Value = "This is a test one [[and a two]] [[and three]] four"
Execute Test
Field Value = "This is a test one [[and a two]] [[and three]] four"

Actual behavior
Set up Test
Field Value = "one [[and a two]] [[and three]] four"
Execute Test
Field Value = "This is a test one [[and a two]] [[and three]] four"
Execute Test
Field Value = "This is a test This is a test one [[and a two]] [[and three]] four"
Execute Test
Field Value = "This is a test This is a test one [[and a two]] [[and three]] four"


Mark S.

unread,
Sep 11, 2017, 1:37:41 PM9/11/17
to TiddlyWiki
I don't know if this is a bug or a feature, but the prepend filter doesn't check to see if what's pre-pending is unique or not.

There's an undocumented filter, unique, which you can use to pack the list. e.g.

+[prepend[This is a test]unique[]]

This will give you the results you expected (I think).

The question is, should the prepend (and probably the other '-pend' operators) check for dupes, or is this a 'feature' that could be useful in some situations?

Have fun,
Mark

c pa

unread,
Sep 11, 2017, 5:42:29 PM9/11/17
to TiddlyWiki
I've been checking some more and maybe I'm completely  missing how these operators work.

This code simply deletes the last item rather than moving the last two items after the item in the variable. This is distressing since the examples only use list items with no spaces, while saying that this is the way (refer to variable) to make it work with items with a space.

Tiddler = action-listops-test4
<br/>
Index Value: {{action-listops-test4!!fieldlist}}

<$button> Reset Test <$action-setfield $tiddler="action-listops-test4" $field="fieldlist" $index="" $value="one [[This is a variable]] [[and a two]] [[and three]] four" /> </$button>
<$vars variable="[[This is a variable]]"> <$button>Execute test <$action-listops $tiddler="action-listops-test4" $field="fieldlist" $index="" filter="" $subfilter="+[putafter:2<variable>]" $tags="" /> </$button> </$vars>

c pa

unread,
Sep 11, 2017, 5:57:52 PM9/11/17
to TiddlyWiki
OK I've created a test suite here:
http://cpashow.tiddlyspot.com/#%24%3A%2F_cpa%2Ftest%2FTest-Suites%2Faction-listops

That steps through all of the operators. Almost all of the operators fail in conjunction with a variable (So we can manually refer to an item with spaces in it)

As a work around next I'll try this with a transclusion rather than a variable

c pa

unread,
Sep 11, 2017, 6:01:05 PM9/11/17
to TiddlyWiki
Also I notice that insertbefore fails because I'm following these instructions

suffix B = the name of a variable containing the title of the tiddler before which this one should be inserted

Mark S.

unread,
Sep 11, 2017, 7:06:04 PM9/11/17
to TiddlyWiki
It needs to be an item, e.g.

 <$vars variable="This is a variable" ...>
Reply all
Reply to author
Forward
0 new messages