1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-24 22:33:16 +00:00

Fix whitespace in x-listops.js and tweak toggle operator (#5024)

* Replaced leading spaces with tabs

* Tweak toggle[] to insert new value in same list position
This commit is contained in:
saqimtiaz 2020-11-15 17:04:03 +01:00 committed by GitHub
parent a2b2e117e3
commit 13499557bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 174 additions and 171 deletions

View File

@ -196,14 +196,16 @@ Extended filter operators to manipulate the current list.
index = results.indexOf(operator.operand),
pairIndex = (operator.operands[1] ? results.indexOf(operator.operands[1]) : -1);
if(index === -1) {
results.push(operator.operand);
if(pairIndex !== -1) {
results.splice(pairIndex,1);
results.splice(pairIndex,1,operator.operand);
} else {
results.push(operator.operand);
}
} else {
results.splice(index,1);
if(operator.operands[1]) {
results.push(operator.operands[1]);
results.splice(index,1,operator.operands[1]);
} else {
results.splice(index,1);
}
}
return results;

View File

@ -758,6 +758,7 @@ function runTests(wiki) {
expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] -[[one]] +[toggle[one]]").join(",")).toBe("two,one");
expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] +[toggle[three],[four]]").join(",")).toBe("one,two,three");
expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] [[three]] +[toggle[three],[four]]").join(",")).toBe("one,two,four");
expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] [[three]] [[four]] +[toggle[three],[five]]").join(",")).toBe("one,two,five,four");
});
it("should handle multiple operands for search-replace", function() {