diff --git a/src/libse/Forms/TimeCodesBeautifier.cs b/src/libse/Forms/TimeCodesBeautifier.cs index 8eb8d03de..a8411ebfa 100644 --- a/src/libse/Forms/TimeCodesBeautifier.cs +++ b/src/libse/Forms/TimeCodesBeautifier.cs @@ -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);