Skip to content

Commit

Permalink
Merge pull request #579 from belka-ew/bug/revert-array-indent-on-line
Browse files Browse the repository at this point in the history
Keep "(" indentation with a "]" in the same line
  • Loading branch information
RazvanN7 authored Apr 7, 2023
2 parents fec7394 + 727472c commit 49b9fe4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/dfmt/formatter.d
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,12 @@ private:

void revertParenIndentation()
{
import std.algorithm.searching : canFind, until;

if (tokens[index .. $].until!(tok => tok.line != current.line).canFind!(x => x.type == tok!"]"))
{
return;
}
if (parenDepthOnLine)
{
foreach (i; 0 .. parenDepthOnLine)
Expand Down
5 changes: 5 additions & 0 deletions tests/allman/keep_break_in_array_arg.d.ref
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ unittest
x
]);
}

void f(T[] x,
const U y)
{
}
5 changes: 5 additions & 0 deletions tests/keep_break_in_array_arg.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ unittest
x
]);
}

void f(T[] x,
const U y)
{
}
5 changes: 5 additions & 0 deletions tests/knr/keep_break_in_array_arg.d.ref
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ unittest {
x
]);
}

void f(T[] x,
const U y)
{
}
4 changes: 4 additions & 0 deletions tests/otbs/keep_break_in_array_arg.d.ref
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ unittest {
x
]);
}

void f(T[] x,
const U y) {
}

0 comments on commit 49b9fe4

Please sign in to comment.