Fix consecutive empty line logic

This commit is contained in:
Matt Nadareski
2024-12-05 21:15:26 -05:00
parent 5a92c0fc98
commit 84fa2f93ea
2 changed files with 11 additions and 11 deletions

View File

@@ -848,25 +848,25 @@ namespace SabreTools.RedumpLib.Test
#endregion
#region RemoveConsecutiveNewlines
#region RemoveConsecutiveEmptyLines
[Fact]
public void RemoveConsecutiveNewlines_Linux_Removed()
public void RemoveConsecutiveEmptyLines_Linux_Removed()
{
string expected = "data\nbase";
string expected = "data\n\nbase";
string newlines = "data\n\n\n\n\n\n\n\n\n\nbase";
string actual = Formatter.RemoveConsecutiveNewlines(newlines);
string actual = Formatter.RemoveConsecutiveEmptyLines(newlines);
Assert.Equal(expected, actual);
}
[Fact]
public void RemoveConsecutiveNewlines_Windows_Removed()
public void RemoveConsecutiveEmptyLines_Windows_Removed()
{
string expected = "data\r\nbase";
string expected = "data\r\n\r\nbase";
string newlines = "data\r\n\r\n\r\n\r\n\r\nbase";
string actual = Formatter.RemoveConsecutiveNewlines(newlines);
string actual = Formatter.RemoveConsecutiveEmptyLines(newlines);
Assert.Equal(expected, actual);
}

View File

@@ -175,7 +175,7 @@ namespace SabreTools.RedumpLib
status = "Formatting complete!";
// Make sure there aren't any instances of two blank lines in a row
return RemoveConsecutiveNewlines(output.ToString());
return RemoveConsecutiveEmptyLines(output.ToString());
}
catch (Exception ex)
{
@@ -754,10 +754,10 @@ namespace SabreTools.RedumpLib
/// <summary>
/// Make sure there aren't any instances of two blank lines in a row
/// </summary>
internal static string RemoveConsecutiveNewlines(string str)
internal static string RemoveConsecutiveEmptyLines(string str)
{
str = Regex.Replace(str, @"(\r\n)+", "\r\n");
return Regex.Replace(str, @"(\n)+", "\n");
str = Regex.Replace(str, @"(\r\n){2,}", "\r\n\r\n");
return Regex.Replace(str, @"(\n){2,}", "\n\n");
}
#endregion