nimpretty: fix #11937 (wrong indentation)

This commit is contained in:
narimiran
2019-08-19 13:35:10 +02:00
parent cf4390a24a
commit ceb742351a
4 changed files with 80 additions and 1 deletions

View File

@@ -441,6 +441,9 @@ proc emitTok*(em: var Emitter; L: TLexer; tok: TToken) =
em.indentLevel = tok.indent
elif (em.lastTok in (splitters + oprSet) and
tok.tokType notin (closedPars - {tkBracketDotRi})):
if tok.tokType in openPars and tok.indent > em.indentStack[^1]:
while em.indentStack[^1] < tok.indent:
em.indentStack.add(em.indentStack[^1] + em.indWidth)
# aka: we are in an expression context:
let alignment = max(tok.indent - em.indentStack[^1], 0)
em.indentLevel = alignment + em.indentStack.high * em.indWidth

View File

@@ -812,7 +812,7 @@ let foo = if cond:
let a =
[[aaadsfas, bbb],
[ccc, ddd]]
[ccc, ddd]]
let b = [
[aaa, bbb],

View File

@@ -71,3 +71,41 @@ proc a() =
# comment 2
discard
proc i11937() =
result = %*
{
"_comment": "pbreports-style JSON",
"attributes": [],
"dataset_uuids": [],
"id": "microbial_asm_polishing_report",
"plotGroups": [],
"tables": [
{
"columns": [
{
"header": "Contig",
"id": "microbial",
"values": values_contig
},
{
"header": "Length",
"id": "microbial",
"values": values_length
},
{
"header": "Circular?",
"id": "microbial",
"values": values_circular
}
],
"id": "microbial_asm_polishing_report.contigs_table",
"title": "Polished contigs from Microbial Assembly"
},
],
"tags": [],
"title": "Microbial Assembly Polishing Report",
"uuid": uuid,
"version": version
}

View File

@@ -71,3 +71,41 @@ proc a() =
# comment 2
discard
proc i11937() =
result = %*
{
"_comment": "pbreports-style JSON",
"attributes": [],
"dataset_uuids": [],
"id": "microbial_asm_polishing_report",
"plotGroups": [],
"tables": [
{
"columns": [
{
"header": "Contig",
"id": "microbial",
"values": values_contig
},
{
"header": "Length",
"id": "microbial",
"values": values_length
},
{
"header": "Circular?",
"id": "microbial",
"values": values_circular
}
],
"id": "microbial_asm_polishing_report.contigs_table",
"title": "Polished contigs from Microbial Assembly"
},
],
"tags": [],
"title": "Microbial Assembly Polishing Report",
"uuid": uuid,
"version": version
}