Custom filter operator overriding the results

49 views
Skip to first unread message

bimlas

unread,
Oct 18, 2018, 5:21:46 PM10/18/18
to TiddlyWikiDev
I working on a filter operator that gathering the "family" of a tiddler, the "field of connection" can be set (defaults to "tags"):

[kindred:<direction>[<field>]]

The current version of the code itself (which works only on prerelease version, needs restart after importing) is on https://github.com/bimlas/TiddlyWiki5/blob/f5790f0973d8c46156cd6ad995491732cbc16b2f/core/modules/filters/kindred.js

About my problem:

The filter works well if I using only one at a time, for example:

[[Drag and Drop]kindred[]]

It's returning the "family" of "Drag and Drop" (every tiddler related to it by tag, recursively):
  • Features
  • TableOfContents 
  • $:/tags/SideBar 
  • DragAndDropMechanism
The problem comes alive when I try to filter this list by another "kindred" filter:

[[Drag and Drop]kindred[]] +[[Features]kindred[]]

With this expression, I would like to get the intersection of the two lists, but it's returning only the results of the second expression. I tried to swap the expressions, in this case the "family" of "Drag and Drop" shown, thus I'm sure that my operator overriding the results list at all. I did another probe:

[[Features]kindred[]] +[tag[Drag and Drop]]

Only "DragAndDropMechanism" is shown in the list (which is good), but when I swap the expressions:

[tag[Drag and Drop]] +[[Features]kindred[]]

than the "family" of "Features" is listed.

I looked at another filter operators ("tag" for example), but I cannot recognize the root of the problem: my operator seems to be correct.

What I doing wrong?

Again, here's the current code (try on prerelease, restart after importing): https://github.com/bimlas/TiddlyWiki5/blob/f5790f0973d8c46156cd6ad995491732cbc16b2f/core/modules/filters/kindred.js

bimlas

unread,
Oct 19, 2018, 6:37:38 AM10/19/18
to TiddlyWikiDev
Ok, I think I found the problem:

I misunderstood the + operator, because I thought that it means "intersection". I just read https://tiddlywiki.com/static/Introduction%2520to%2520filter%2520notation.html -> Combination which says that the results of the first filter is the input to the second (+ signed) filter. So my filter operator not works, because

+[[Features]kindred[]]

is overwriting the "input" and replacing it with "Features" tiddler.

I just made some small modifications on the code, see https://github.com/bimlas/TiddlyWiki5/tree/kindred-filter branch for the latest.

bimlas

unread,
Oct 19, 2018, 9:31:56 AM10/19/18
to TiddlyWikiDev
Reply all
Reply to author
Forward
0 new messages