Skip to content

Commit

Permalink
Merge branch 'main' into vscode-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
belav authored Jan 4, 2025
2 parents eca9569 + c9b6288 commit c0d9ec7
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 4 deletions.
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
# 0.30.4
# 0.30.5
## What's Changed
### Extra blank line added to file each time csharpier runs on this file [#1426](https://github.com/belav/csharpier/issues/1426)
When a file ended in a comment and that comment had multiple blank lines before it, a new blank line was being added each time it was formatted.
// input
```c#
// input
namespace MyCompany.MyNamespace;


// Comment block
// 0.30.4
namespace MyCompany.MyNamespace;



// Comment block
// 0.30.5
namespace MyCompany.MyNamespace;

// Comment block
**Full Changelog**: https://github.com/belav/csharpier/compare/0.30.4...0.30.5
# 0.30.4
## What's Changed
### Formatting deletes `unsafe` modifier [#1416](https://github.com/belav/csharpier/issues/1416)
Formatting a using directive with an unsafe modifier resulted in the lose of the unsafe keyword
Expand Down
2 changes: 1 addition & 1 deletion Nuget/Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.30.4</Version>
<Version>0.30.5</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/belav/csharpier</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using System;

namespace MyCompany.MyNamespace;

// Comment block
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace MyCompany.MyNamespace;




// Comment block
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public static Doc Print(CompilationUnitSyntax node, PrintingContext context)

NamespaceLikePrinter.Print(node, docs, context);

// this is what ends up adding multiple HardLineSkipBreakIfFirstInGroup, but it is needed for some cases
// and trying to change the logic in there to not print multiple lines was taking me down a rabbit hole
var finalTrivia = Token.PrintLeadingTriviaWithNewLines(
node.EndOfFileToken.LeadingTrivia,
context
Expand All @@ -17,14 +19,16 @@ public static Doc Print(CompilationUnitSyntax node, PrintingContext context)
// really ugly code to prevent a comment at the end of a file from continually inserting new blank lines
if (
finalTrivia is Concat { Contents.Count: > 1 } list
&& list.Contents[1] is LeadingComment
&& docs.Count > 0
&& docs[^1] is Concat { Contents.Count: > 1 } previousList
&& previousList.Contents[^1] is HardLine
&& previousList.Contents[^2] is HardLine
)
{
list.Contents.RemoveAt(0);
while (list.Contents[0] is HardLine { SkipBreakIfFirstInGroup: true })
{
list.Contents.RemoveAt(0);
}

docs.Add(finalTrivia);
}
Expand Down
5 changes: 5 additions & 0 deletions Src/Website/docs/EditorsTroubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ The following can help track down issues with the extension being unable to inst
4. If the installation appears to be corrupt, delete the directory and install CSharpier there yourself<br/>
`dotnet tool install csharpier --version [CSharpierVersion] --tool-path [PathFromStep2]`
5. Repeat step 3 to validate the install

## Known Issues
`Spawning the csharpier server timed out. Formatting cannot occur.`

The new CSharpier Server has caused issues with some users. There is an option `Disable CSharpier Server` to have the extension make use of the older method of communicating with csharpier.
5 changes: 5 additions & 0 deletions docs/EditorsTroubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ The following can help track down issues with the extension being unable to inst
4. If the installation appears to be corrupt, delete the directory and install CSharpier there yourself<br/>
`dotnet tool install csharpier --version [CSharpierVersion] --tool-path [PathFromStep2]`
5. Repeat step 3 to validate the install

## Known Issues
`Spawning the csharpier server timed out. Formatting cannot occur.`

The new CSharpier Server has caused issues with some users. There is an option `Disable CSharpier Server` to have the extension make use of the older method of communicating with csharpier.

0 comments on commit c0d9ec7

Please sign in to comment.