Merge pull request #8921 from Flitskikker/feature/btc-bugfix-20241018

Small "Beautify time codes" improvement
This commit is contained in:
Nikolaj Olsson 2024-10-20 12:55:27 +02:00 committed by GitHub
commit a2a226a2b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,7 +111,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
}
}
private bool FixConnectedSubtitles(Paragraph leftParagraph = null, Paragraph rightParagraph = null)
private bool FixConnectedSubtitles(Paragraph leftParagraph = null, Paragraph rightParagraph = null, bool checkConnected = true)
{
if (leftParagraph == null || rightParagraph == null)
{
@ -140,7 +140,7 @@ namespace Nikse.SubtitleEdit.Core.Forms
var subtitlesAreConnected = distance < Configuration.Settings.BeautifyTimeCodes.Profile.ConnectedSubtitlesTreatConnected;
if (subtitlesAreConnected)
if (subtitlesAreConnected || !checkConnected)
{
var newLeftOutCueFrame = MillisecondsToFrames(leftParagraph.EndTime.TotalMilliseconds);
var newRightInCueFrame = MillisecondsToFrames(rightParagraph.StartTime.TotalMilliseconds);
@ -539,6 +539,17 @@ namespace Nikse.SubtitleEdit.Core.Forms
bestRightInCueFrame = newRightInCueFrame;
}
// Re-check if, with the new cues, the subtitles are actually connected
var newDistance = FramesToMilliseconds(bestRightInCueFrame) - FramesToMilliseconds(bestLeftOutCueFrame);
if (newDistance < Configuration.Settings.BeautifyTimeCodes.Profile.ConnectedSubtitlesTreatConnected)
{
// Yes, so handle using the designated function, ignoring its check connected check
// (because otherwise it would have handled it before going into the FixChainableSubtitles function)
FixConnectedSubtitles(leftParagraph, rightParagraph, checkConnected: false);
return true;
}
// Check cases
var isLeftOutCueOnShotChange = IsCueOnShotChange(bestLeftOutCueFrame, false);
var isRightInCueOnShotChange = IsCueOnShotChange(bestRightInCueFrame, true);