1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Merge pull request #172 from Brennall/FilterLimitBug

Filter limit bug
This commit is contained in:
Jeremy Ruston 2013-10-01 13:57:04 -07:00
commit e57148b034
2 changed files with 2 additions and 1 deletions

View File

@ -28,7 +28,7 @@ exports.limit = function(source,operator,options) {
// Slice the array if necessary
var limit = Math.min(source.length,parseInt(operator.operand,10));
if(operator.prefix === "!") {
results = source.slice(source.length - limit,limit);
results = source.slice(source.length - limit);
} else {
results = source.slice(0,limit);
}

View File

@ -141,6 +141,7 @@ describe("Filter tests", function() {
it("should handle the limit operator", function() {
expect(wiki.filterTiddlers("[!is[system]sort[title]limit[2]]").join(",")).toBe("a fourth tiddler,one");
expect(wiki.filterTiddlers("[prefix[Tid]sort[title]limit[1]]").join(",")).toBe("Tiddler Three");
expect(wiki.filterTiddlers("[prefix[Tid]sort[title]!limit[1]]").join(",")).toBe("TiddlerOne");
});
it("should handle the list operator", function() {