From c13db1f4a7ecd49272e0e0f11b4fb8b34f74889d Mon Sep 17 00:00:00 2001 From: "Martijn van Berkel (Flitskikker)" Date: Sun, 20 Oct 2024 12:23:57 +0200 Subject: [PATCH] More general approach --- src/libse/Forms/TimeCodesBeautifier.cs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/libse/Forms/TimeCodesBeautifier.cs b/src/libse/Forms/TimeCodesBeautifier.cs index 4a75105e5..dd54056da 100644 --- a/src/libse/Forms/TimeCodesBeautifier.cs +++ b/src/libse/Forms/TimeCodesBeautifier.cs @@ -539,23 +539,24 @@ namespace Nikse.SubtitleEdit.Core.Forms bestRightInCueFrame = newRightInCueFrame; } - // Check cases - var isLeftOutCueOnShotChange = IsCueOnShotChange(bestLeftOutCueFrame, false); - var isRightInCueOnShotChange = IsCueOnShotChange(bestRightInCueFrame, true); - - var performGeneralChaining = false; - - if (isLeftOutCueOnShotChange && isRightInCueOnShotChange - && bestLeftOutCueFrameInfo.result == FindBestCueResult.SnappedToRedZone && bestRightInCueFrameInfo.result == FindBestCueResult.SnappedToRedZone - && bestLeftOutCueFrame == bestRightInCueFrame) + // 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) { - // If both cues are being snapped to the exact same shot change, the subtitles really are connected - // So, handle using the designated function, ignoring the "treat connected" value (because otherwise it would have handled it before going into this function) + // 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; } - else if (isRightInCueOnShotChange) + + // Check cases + var isLeftOutCueOnShotChange = IsCueOnShotChange(bestLeftOutCueFrame, false); + var isRightInCueOnShotChange = IsCueOnShotChange(bestRightInCueFrame, true); + + var performGeneralChaining = false; + + if (isRightInCueOnShotChange) { // The right in cue is on a shot change // Try to chain the subtitles