From d8b291bc0460d493d116ea2401a7d8a3e7fbb9a7 Mon Sep 17 00:00:00 2001 From: Rob Hoelz Date: Mon, 17 Dec 2018 05:19:48 -0600 Subject: [PATCH] Fix search method for search tokens spread across fields (#3641) * Fix search method for search tokens spread across fields Addresses GH #3636, which reports that if you're searching for "test body", and "test" only appears in the title field, and "body" only appears in the text field, 5.1.18's search method won't yield that tiddler as a result, which appears to be a regression from the 5.1.17 behavior * Add test for searching for multiple tokens across fields Verifies GH #3636: > If I create a tiddler in the empty edition with the title "Test tiddler" and content "Body content", searching the wiki for "test body" yields no results under either "title matches" or "all matches". Searching for either word individually turns up "Test tiddler", and repeating this in an empty wiki I created from the 5.1.17 tag causes "Test tiddler" to show up under "all matches". --- core/modules/wiki.js | 40 ++++++++------------ editions/test/tiddlers/tests/test-filters.js | 4 ++ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/core/modules/wiki.js b/core/modules/wiki.js index 806229866..74ba082d4 100755 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -1119,6 +1119,8 @@ exports.search = function(text,options) { if(!searchTermsRegExps) { return true; } + var notYetFound = searchTermsRegExps.slice(); + var tiddler = self.getTiddler(title); if(!tiddler) { tiddler = new $tw.Tiddler({title: title, text: "", type: "text/vnd.tiddlywiki"}); @@ -1137,50 +1139,40 @@ exports.search = function(text,options) { } else { searchFields = fields; } - for(var fieldIndex=0; fieldIndex0 && fieldIndex