Skip to content

Commit 74ad911

Browse files
authored
feat: remove any blank lines after documentation comments (#1526)
closes #1521
1 parent e2b4951 commit 74ad911

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

Src/CSharpier.Tests/CSharpier.Tests.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,4 @@
3636
<DependentUpon>$([System.String]::Copy(%(Filename)).Replace('.expected', '.test'))</DependentUpon>
3737
</Content>
3838
</ItemGroup>
39-
<ItemGroup>
40-
<Folder Include="FormattingTests\TestFiles\csproj\" />
41-
</ItemGroup>
4239
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class ClassName
2+
{
3+
/// <summary>Remove the lines after the summary</summary>
4+
public bool SomeField1;
5+
6+
/* Don't remove this line */
7+
8+
public bool SomeField2;
9+
10+
// Don't remove this line
11+
12+
public bool SomeField2;
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class ClassName
2+
{
3+
/// <summary>Remove the lines after the summary</summary>
4+
5+
public bool SomeField1;
6+
7+
/* Don't remove this line */
8+
9+
public bool SomeField2;
10+
11+
// Don't remove this line
12+
13+
public bool SomeField2;
14+
}

Src/CSharpier/SyntaxPrinter/Token.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,17 @@ private static Doc PrivatePrintLeadingTrivia(
250250
{
251251
printNewLines = false;
252252
}
253-
docs.Add(Doc.HardLineSkipBreakIfFirstInGroup);
253+
254+
if (
255+
!(
256+
docs.Count > 1
257+
&& docs[^1] == Doc.HardLineSkipBreakIfFirstInGroup
258+
&& docs[^2] is LeadingComment { Type: CommentType.SingleLine }
259+
)
260+
)
261+
{
262+
docs.Add(Doc.HardLineSkipBreakIfFirstInGroup);
263+
}
254264
}
255265
if (kind is not (SyntaxKind.EndOfLineTrivia or SyntaxKind.WhitespaceTrivia))
256266
{

0 commit comments

Comments
 (0)