Skip to content

Commit 49b9fe4

Browse files
authored
Merge pull request #579 from belka-ew/bug/revert-array-indent-on-line
Keep "(" indentation with a "]" in the same line
2 parents fec7394 + 727472c commit 49b9fe4

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

src/dfmt/formatter.d

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,12 @@ private:
720720

721721
void revertParenIndentation()
722722
{
723+
import std.algorithm.searching : canFind, until;
724+
725+
if (tokens[index .. $].until!(tok => tok.line != current.line).canFind!(x => x.type == tok!"]"))
726+
{
727+
return;
728+
}
723729
if (parenDepthOnLine)
724730
{
725731
foreach (i; 0 .. parenDepthOnLine)

tests/allman/keep_break_in_array_arg.d.ref

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ unittest
44
x
55
]);
66
}
7+
8+
void f(T[] x,
9+
const U y)
10+
{
11+
}

tests/keep_break_in_array_arg.d

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ unittest
44
x
55
]);
66
}
7+
8+
void f(T[] x,
9+
const U y)
10+
{
11+
}

tests/knr/keep_break_in_array_arg.d.ref

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ unittest {
33
x
44
]);
55
}
6+
7+
void f(T[] x,
8+
const U y)
9+
{
10+
}

tests/otbs/keep_break_in_array_arg.d.ref

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ unittest {
33
x
44
]);
55
}
6+
7+
void f(T[] x,
8+
const U y) {
9+
}

0 commit comments

Comments
 (0)