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

fixing issue when formatting with tabs that would convert tabs in com… #1344

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
public class Foo
{
/**
* comment
*/
public class Bar
{
/**
* comment
*/
var x = 0;
}

public void SomeFunction()
{
/*
The following line is an example with an indent:
This line is indented by one tab.
*/
/*
The following line is an example with an indent:
This line is indented by 4 spaces but will be converted to 1 tab
*/
/*
The following line is an example with an indent:
This line is indented by 3 spaces but will be left as 3 spaces
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,20 @@ public class Foo
*/
var x = 0;
}

public void SomeFunction()
{
/*
The following line is an example with an indent:
This line is indented by one tab.
*/
/*
The following line is an example with an indent:
This line is indented by 4 spaces but will be converted to 1 tab
*/
/*
The following line is an example with an indent:
This line is indented by 3 spaces but will be left as 3 spaces
*/
}
}
6 changes: 6 additions & 0 deletions Src/CSharpier/DocPrinter/DocPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ int CalculateIndentLength(string line) =>
this.Output.Append(indent.Value);
spacesToAppend -= indentLength;
}

while (spacesToAppend > 0 && spacesToAppend >= this.PrinterOptions.IndentSize)
{
this.Output.Append('\t');
spacesToAppend -= this.PrinterOptions.IndentSize;
}
}
if (spacesToAppend > 0)
{
Expand Down
Loading