Fix double array indentation inside parens

This commit is contained in:
Eugen Wissner 2021-06-10 20:23:07 +02:00
parent e79ba9f0c8
commit e0549070a1
No known key found for this signature in database
GPG Key ID: A27FDC1E8EE902C0
7 changed files with 86 additions and 82 deletions

View File

@ -629,6 +629,10 @@ private:
} }
else if (arrayInitializerStart && isMultilineAt(index - 1)) else if (arrayInitializerStart && isMultilineAt(index - 1))
{ {
if (peekBack2Is(tok!"(")) {
indents.pop();
}
// Use the close bracket as the indent token to distinguish // Use the close bracket as the indent token to distinguish
// the array initialiazer from an array index in the newline // the array initialiazer from an array index in the newline
// handling code // handling code

View File

@ -1,7 +1,7 @@
unittest unittest
{ {
foo([ foo([
target.value.region[1], target.value.region[1], target.value.region[1], target.value.region[1], target.value.region[1],
target.value.region[1], target.value.region[1], target.value.region[1] target.value.region[1], target.value.region[1]
]); ]);
} }

View File

@ -1,24 +1,24 @@
unittest unittest
{ {
Bson base = Bson([ Bson base = Bson([
"maps": Bson([ "maps": Bson([
Bson(["id": Bson(4), "comment": Bson("hello")]), Bson(["id": Bson(4), "comment": Bson("hello")]),
Bson(["id": Bson(49), "comment": Bson(null)]) Bson(["id": Bson(49), "comment": Bson(null)])
]), ]),
"short": Bson(["a": "b", "c": "d"]), "short": Bson(["a": "b", "c": "d"]),
"numbers": Bson([ "numbers": Bson([
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 3, 4, 5, 6, 7, 8, 9, 0
]), ]),
"shuffleOnReset": serializeToBson([ "shuffleOnReset": serializeToBson([
"all": false, "all": false,
"selected": true, "selected": true,
"maybe": false "maybe": false
]), ]),
"resetOnEmpty": Bson(false), "resetOnEmpty": Bson(false),
"applyMods": Bson(true), "applyMods": Bson(true),
"sendComments": Bson(true) "sendComments": Bson(true)
]); ]);
int[] x = [ int[] x = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0

View File

@ -1,25 +1,25 @@
auto find() auto find()
{ {
return Map.findRange([ return Map.findRange([
"$and": [ "$and": [
["deleted": Bson(false)], ["deleted": Bson(false)],
[ [
"$or": Bson([ "$or": Bson([
serializeToBson(["forceUpdate": Bson(true)]), serializeToBson(["forceUpdate": Bson(true)]),
serializeToBson([ serializeToBson([
"info.approved": ["$eq": Bson(1)], "info.approved": ["$eq": Bson(1)],
"fetchDate": [ "fetchDate": [
"$lte": Bson(BsonDate(currentTime - 60.days)) "$lte": Bson(BsonDate(currentTime - 60.days))
] ]
]), ]),
serializeToBson([ serializeToBson([
"info.approved": ["$ne": Bson(1)], "info.approved": ["$ne": Bson(1)],
"fetchDate": [ "fetchDate": [
"$lte": Bson(BsonDate(currentTime - 14.days)) "$lte": Bson(BsonDate(currentTime - 14.days))
] ]
]) ])
]) ])
]
] ]
]); ]
]);
} }

View File

@ -1,6 +1,6 @@
unittest { unittest {
foo([ foo([
target.value.region[1], target.value.region[1], target.value.region[1], target.value.region[1], target.value.region[1],
target.value.region[1], target.value.region[1], target.value.region[1] target.value.region[1], target.value.region[1]
]); ]);
} }

View File

@ -1,23 +1,23 @@
unittest { unittest {
Bson base = Bson([ Bson base = Bson([
"maps": Bson([ "maps": Bson([
Bson(["id": Bson(4), "comment": Bson("hello")]), Bson(["id": Bson(4), "comment": Bson("hello")]),
Bson(["id": Bson(49), "comment": Bson(null)]) Bson(["id": Bson(49), "comment": Bson(null)])
]), ]),
"short": Bson(["a": "b", "c": "d"]), "short": Bson(["a": "b", "c": "d"]),
"numbers": Bson([ "numbers": Bson([
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 3, 4, 5, 6, 7, 8, 9, 0
]), ]),
"shuffleOnReset": serializeToBson([ "shuffleOnReset": serializeToBson([
"all": false, "all": false,
"selected": true, "selected": true,
"maybe": false "maybe": false
]), ]),
"resetOnEmpty": Bson(false), "resetOnEmpty": Bson(false),
"applyMods": Bson(true), "applyMods": Bson(true),
"sendComments": Bson(true) "sendComments": Bson(true)
]); ]);
int[] x = [ int[] x = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0

View File

@ -1,24 +1,24 @@
auto find() { auto find() {
return Map.findRange([ return Map.findRange([
"$and": [ "$and": [
["deleted": Bson(false)], ["deleted": Bson(false)],
[ [
"$or": Bson([ "$or": Bson([
serializeToBson(["forceUpdate": Bson(true)]), serializeToBson(["forceUpdate": Bson(true)]),
serializeToBson([ serializeToBson([
"info.approved": ["$eq": Bson(1)], "info.approved": ["$eq": Bson(1)],
"fetchDate": [ "fetchDate": [
"$lte": Bson(BsonDate(currentTime - 60.days)) "$lte": Bson(BsonDate(currentTime - 60.days))
] ]
]), ]),
serializeToBson([ serializeToBson([
"info.approved": ["$ne": Bson(1)], "info.approved": ["$ne": Bson(1)],
"fetchDate": [ "fetchDate": [
"$lte": Bson(BsonDate(currentTime - 14.days)) "$lte": Bson(BsonDate(currentTime - 14.days))
] ]
]) ])
]) ])
]
] ]
]); ]
]);
} }