Skip to content

Commit

Permalink
Revert operator indentation in an argument list
Browse files Browse the repository at this point in the history
  • Loading branch information
belka-ew authored and WebFreak001 committed Feb 6, 2023
1 parent a4fbc6f commit dba8c87
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dfmt/formatter.d
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ private:
const commaLine = tokens[index].line;

writeToken();
if (indents.topIs(tok!"."))
if (indents.topIsWrap && !indents.topIs(tok!","))
{
indents.pop;
}
Expand All @@ -1647,7 +1647,7 @@ private:
{
pushWrapIndent();
writeToken();
if (indents.topIs(tok!"."))
if (indents.topIsWrap && !indents.topIs(tok!","))
{
indents.pop;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/allman/argument_chain_indent.d.ref
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ class C
.map.map.map.map.map.map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __LINE__);

g(map && map && map && map && map && map && map && map && map && map && map
&& map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __LINE__);
h(map || map || map || map || map || map || map || map || map || map || map
|| map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __LINE__);
i(map + map + map + map + map + map + map + map + map + map + map + map + map
+ map + map + map + map + map, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __FILE__, __FILE__, __LINE__);
}
}
}
16 changes: 16 additions & 0 deletions tests/allman/argument_chain_keep_breaks.d.ref
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ class C
.to!string,
__FILE__,
__LINE__);

g(
map &&
map,
__FILE__,
__LINE__);
h(
map ||
map,
__FILE__,
__LINE__);
i(
map
+ map,
__FILE__,
__LINE__);
}
}
}
32 changes: 32 additions & 0 deletions tests/argument_chain_indent.d
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,38 @@ class C
__FILE__,
__FILE__,
__LINE__);

g(
map && map && map && map && map && map && map && map && map && map && map && map,
__FILE__,
__FILE__,
__FILE__,
__FILE__,
__FILE__,
__FILE__,
__FILE__,
__LINE__);
h(
map || map || map || map || map || map || map || map || map || map || map || map,
__FILE__,
__FILE__,
__FILE__,
__FILE__,
__FILE__,
__FILE__,
__FILE__,
__LINE__);
i(
map + map + map + map + map + map + map + map + map + map + map + map + map + map + map + map + map
+ map,
__FILE__,
__FILE__,
__FILE__,
__FILE__,
__FILE__,
__FILE__,
__FILE__,
__LINE__);
}
}
}
16 changes: 16 additions & 0 deletions tests/argument_chain_keep_breaks.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ class C
.to!string,
__FILE__,
__LINE__);

g(
map &&
map,
__FILE__,
__LINE__);
h(
map ||
map,
__FILE__,
__LINE__);
i(
map
+ map,
__FILE__,
__LINE__);
}
}
}
10 changes: 10 additions & 0 deletions tests/knr/argument_chain_indent.d.ref
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ class C {
.map.map.map.map.map.map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __LINE__);

g(map && map && map && map && map && map && map && map && map && map && map
&& map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __LINE__);
h(map || map || map || map || map || map || map || map || map || map || map
|| map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __LINE__);
i(map + map + map + map + map + map + map + map + map + map + map + map + map
+ map + map + map + map + map, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __FILE__, __FILE__, __LINE__);
}
}
}
16 changes: 16 additions & 0 deletions tests/knr/argument_chain_keep_breaks.d.ref
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ class C {
.to!string,
__FILE__,
__LINE__);

g(
map &&
map,
__FILE__,
__LINE__);
h(
map ||
map,
__FILE__,
__LINE__);
i(
map
+ map,
__FILE__,
__LINE__);
}
}
}
10 changes: 10 additions & 0 deletions tests/otbs/argument_chain_indent.d.ref
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ class C {
.map.map.map.map.map.map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __FILE__, __FILE__, __FILE__, __LINE__);

g(map && map && map && map && map && map && map && map && map && map && map
&& map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __LINE__);
h(map || map || map || map || map || map || map || map || map || map || map
|| map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __LINE__);
i(map + map + map + map + map + map + map + map + map + map + map + map + map
+ map + map + map + map + map, __FILE__, __FILE__, __FILE__,
__FILE__, __FILE__, __FILE__, __FILE__, __LINE__);
}
}
}
16 changes: 16 additions & 0 deletions tests/otbs/argument_chain_keep_breaks.d.ref
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ class C {
.to!string,
__FILE__,
__LINE__);

g(
map &&
map,
__FILE__,
__LINE__);
h(
map ||
map,
__FILE__,
__LINE__);
i(
map
+ map,
__FILE__,
__LINE__);
}
}
}

0 comments on commit dba8c87

Please sign in to comment.