mirror of
https://github.com/zotero/zotero.git
synced 2026-10-07 02:58:09 +00:00
fix quicksearch phrase search not respecting scope (#4608)
Fixes: #4381
This commit is contained in:
parent
78077fab9d
commit
82d50676d3
2 changed files with 26 additions and 0 deletions
|
|
@ -700,6 +700,10 @@ Zotero.Search.prototype.search = Zotero.Promise.coroutine(function* (asTempTable
|
|||
for (let split of splits){
|
||||
s.addCondition('fulltextWord', condition.operator, split);
|
||||
}
|
||||
// If applicable, only search for words within specified scope (e.g. collection)
|
||||
if (this._scope) {
|
||||
s.setScope(this._scope, true);
|
||||
}
|
||||
numSplits = splits.length;
|
||||
let wordMatches = yield s.search();
|
||||
|
||||
|
|
|
|||
|
|
@ -634,6 +634,28 @@ describe("Zotero.Search", function() {
|
|||
// TEMP: Match parent attachment
|
||||
assert.sameMembers(matches, [attachment.id]);
|
||||
});
|
||||
|
||||
it("should not include items outside of scope during phrase search", async function () {
|
||||
var col = await createDataObject('collection');
|
||||
fooItem.addToCollection(col.id);
|
||||
await fooItem.saveTx();
|
||||
|
||||
// Quicksearch from a collection
|
||||
let collectionScope = new Zotero.Search();
|
||||
collectionScope.libraryID = userLibraryID;
|
||||
collectionScope.addCondition('noChildren', 'true');
|
||||
collectionScope.addCondition('collectionID', 'is', col.id);
|
||||
|
||||
var s = new Zotero.Search();
|
||||
s.libraryID = userLibraryID;
|
||||
// Phrase search
|
||||
s.addCondition('quicksearch-everything', 'contains', '"foo"');
|
||||
s.setScope(collectionScope, true);
|
||||
var matches = await s.search();
|
||||
// Only the item from the collection is returned
|
||||
assert.equal(matches.length, 1);
|
||||
assert.equal(matches[0], fooItem.id);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue