Skip to content

Commit

Permalink
fixing issue when formatting with tabs that would convert tabs in com… (
Browse files Browse the repository at this point in the history
belav#1344)

…ments into spaces.

closes belav#1343
  • Loading branch information
belav authored and pisolofin committed Sep 24, 2024
1 parent 93160ce commit f13c02d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
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

0 comments on commit f13c02d

Please sign in to comment.