Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #432 #590

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/dfmt/formatter.d
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,14 @@ private:
if (niBraceDepth > 0)
niBraceDepth--;

// Account for possible function literals in this array which offset
// the previously set index (pos). Fixes issue #432.
while(astInformation.indentInfoSortedByEndLocation[pos].endLocation !=
WebFreak001 marked this conversation as resolved.
Show resolved Hide resolved
tokens[index].index)
{
pos++;
}

auto indentInfo = astInformation.indentInfoSortedByEndLocation[pos];
if (indentInfo.flags & BraceIndentInfoFlags.tempIndent)
{
Expand Down
17 changes: 17 additions & 0 deletions tests/allman/issue0432.d.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
struct S
{
ulong x;
ulong y;
ulong z;
ulong w;
}

immutable int function(int) f = (x) { return x + 1111; };

immutable S s = {
1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111,
};

void main()
{
}
19 changes: 19 additions & 0 deletions tests/issue0432.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
struct S
{
ulong x;
ulong y;
ulong z;
ulong w;
}

immutable int function(int) f = (x) { return x + 1111; };

immutable S s = {
1111111111111111111,
1111111111111111111,
1111111111111111111,
1111111111111111111,};

void main()
{
}
16 changes: 16 additions & 0 deletions tests/knr/issue0432.d.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
struct S {
ulong x;
ulong y;
ulong z;
ulong w;
}

immutable int function(int) f = (x) { return x + 1111; };

immutable S s = {
1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111,
};

void main()
{
}
15 changes: 15 additions & 0 deletions tests/otbs/issue0432.d.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
struct S {
ulong x;
ulong y;
ulong z;
ulong w;
}

immutable int function(int) f = (x) { return x + 1111; };

immutable S s = {
1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111,
};

void main() {
}
Loading