Skip to content

Commit e2046aa

Browse files
committed
fix newline issues
1 parent 82ca0c5 commit e2046aa

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Discord.Net.ComponentDesigner.Generator/Utils/StringUtils.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ public static string NormalizeIndentation(this string str)
3939
var rawLines = str.Split('\n');
4040
var lines = new List<string>(rawLines);
4141

42-
var minSpacing = lines.Min(x =>
43-
string.IsNullOrWhiteSpace(x) ? int.MaxValue : x.TakeWhile(char.IsWhiteSpace).Count()
44-
);
45-
46-
if (minSpacing is 0 or int.MaxValue) return str;
47-
4842
// remove leading empty lines
4943
foreach (var line in rawLines)
5044
{
@@ -59,10 +53,16 @@ public static string NormalizeIndentation(this string str)
5953
else break;
6054
}
6155

56+
var minSpacing = lines.Min(x =>
57+
x.TakeWhile(char.IsWhiteSpace).Count()
58+
);
59+
60+
if (minSpacing is 0 or int.MaxValue) return str;
61+
6262
return string.Join(
6363
"\n",
6464
lines.Select(x =>
65-
x.Length > minSpacing ? x.Substring(minSpacing) : x
65+
x.Length > minSpacing ? x.Substring(minSpacing) : string.Empty
6666
)
6767
);
6868
}

0 commit comments

Comments
 (0)