Skip to content

Commit eb8f69d

Browse files
committed
Merge subfilter fix from #9595
1 parent 5b96929 commit eb8f69d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

core/modules/filters.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ exports.getFilterRunPrefixes = function() {
230230
return this.filterRunPrefixes;
231231
}
232232

233-
exports.filterTiddlers = function(filterString,widget,source) {
234-
var fn = this.compileFilter(filterString);
233+
exports.filterTiddlers = function(filterString,widget,source,options) {
234+
var fn = this.compileFilter(filterString,options);
235235
try {
236236
const fnResult = fn.call(this,source,widget);
237237
return fnResult;
@@ -244,8 +244,11 @@ exports.filterTiddlers = function(filterString,widget,source) {
244244
Compile a filter into a function with the signature fn(source,widget) where:
245245
source: an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title)
246246
widget: an optional widget node for retrieving the current tiddler etc.
247+
options: optional hashmap of options
248+
options.defaultFilterRunPrefix: the default filter run prefix to use when none is specified
247249
*/
248-
exports.compileFilter = function(filterString) {
250+
exports.compileFilter = function(filterString,options) {
251+
var defaultFilterRunPrefix = options?.defaultFilterRunPrefix || "or";
249252
if(!this.filterCache) {
250253
this.filterCache = Object.create(null);
251254
this.filterCacheCount = 0;
@@ -354,7 +357,7 @@ exports.compileFilter = function(filterString) {
354357
var options = {wiki: self, suffixes: operation.suffixes || []};
355358
switch(operation.prefix || "") {
356359
case "": // No prefix means that the operation is unioned into the result
357-
return filterRunPrefixes["or"](operationSubFunction, options);
360+
return filterRunPrefixes[defaultFilterRunPrefix](operationSubFunction, options);
358361
case "=": // The results of the operation are pushed into the result without deduplication
359362
return filterRunPrefixes["all"](operationSubFunction, options);
360363
case "-": // The results of this operation are removed from the main result

core/modules/filters/subfilter.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ Filter operator returning its operand evaluated as a filter
1313
Export our filter function
1414
*/
1515
exports.subfilter = function(source,operator,options) {
16-
var list = options.wiki.filterTiddlers(operator.operand,options.widget,source);
16+
var suffixes = operator.suffixes || [],
17+
defaultFilterRunPrefix = (suffixes[0] || [])[0] || "or";
18+
var list = options.wiki.filterTiddlers(operator.operand,options.widget,source,{defaultFilterRunPrefix});
1719
if(operator.prefix === "!") {
1820
var results = [];
1921
source(function(tiddler,title) {

0 commit comments

Comments
 (0)