mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
"Unbreak lines" now works with multiple new line characters - thx ivandrofly :)
Fix #1702
This commit is contained in:
parent
7e8ac0de9a
commit
f6b54dac40
@ -681,10 +681,11 @@ namespace Nikse.SubtitleEdit.Core
|
||||
|
||||
public static string UnbreakLine(string text)
|
||||
{
|
||||
if (!text.Contains(Environment.NewLine))
|
||||
var lines = text.SplitToLines();
|
||||
if (lines.Length == 1)
|
||||
return text;
|
||||
|
||||
var singleLine = text.Replace(Environment.NewLine, " ");
|
||||
var singleLine = string.Join(" ", lines);
|
||||
while (singleLine.Contains(" "))
|
||||
singleLine = singleLine.Replace(" ", " ");
|
||||
|
||||
|
@ -8422,7 +8422,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void ButtonUnBreakClick(object sender, EventArgs e)
|
||||
{
|
||||
// Disable Autobreak feature.
|
||||
_doAutoBreakOnTextChanged = false;
|
||||
if (SubtitleListview1.SelectedItems.Count > 1)
|
||||
{
|
||||
@ -8442,7 +8441,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
textBoxListViewText.Text = Utilities.UnbreakLine(textBoxListViewText.Text);
|
||||
}
|
||||
// Enable Autobreak feature.
|
||||
_doAutoBreakOnTextChanged = true;
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,34 @@ namespace Test.Logic
|
||||
Assert.AreEqual("- Je veux voir ce qu'ils veulent être." + Environment.NewLine + "- Qu'est ce qui se passe ?", s2);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnBreakLine1()
|
||||
{
|
||||
string s = Utilities.UnbreakLine("Hallo!" + Environment.NewLine + "Hallo!");
|
||||
Assert.AreEqual("Hallo! Hallo!", s);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnBreakLine2()
|
||||
{
|
||||
string s = Utilities.UnbreakLine("Hallo!\nHallo!");
|
||||
Assert.AreEqual("Hallo! Hallo!", s);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnBreakLine3()
|
||||
{
|
||||
string s = Utilities.UnbreakLine("Hallo!\r\nHallo!");
|
||||
Assert.AreEqual("Hallo! Hallo!", s);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnBreakLine4()
|
||||
{
|
||||
string s = Utilities.UnbreakLine("Hallo! \nHallo!");
|
||||
Assert.AreEqual("Hallo! Hallo!", s);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FixInvalidItalicTags2()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user