From 7e6d3c24242485d4c51d7937adbb2ad71b5bc52f Mon Sep 17 00:00:00 2001 From: "Martijn van Berkel (Flitskikker)" Date: Wed, 21 Feb 2024 11:43:27 +0100 Subject: [PATCH] Fix two distance calculations (overlap detection) --- src/libse/Forms/TimeCodesBeautifier.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libse/Forms/TimeCodesBeautifier.cs b/src/libse/Forms/TimeCodesBeautifier.cs index 6c6ff4cb5..00c363b94 100644 --- a/src/libse/Forms/TimeCodesBeautifier.cs +++ b/src/libse/Forms/TimeCodesBeautifier.cs @@ -886,7 +886,7 @@ namespace Nikse.SubtitleEdit.Core.Forms var previousParagraph = _subtitle.Paragraphs.ElementAtOrDefault(index - 1); if (previousParagraph != null) { - var distance = previousParagraph.StartTime.TotalMilliseconds - paragraph.EndTime.TotalMilliseconds; + var distance = paragraph.StartTime.TotalMilliseconds - previousParagraph.EndTime.TotalMilliseconds; // If an overlap threshold is set, don't fix if threshold exceeded if (distance < 0 && Configuration.Settings.BeautifyTimeCodes.OverlapThreshold > 0 && Math.Abs(distance) >= Configuration.Settings.BeautifyTimeCodes.OverlapThreshold) @@ -910,7 +910,7 @@ namespace Nikse.SubtitleEdit.Core.Forms var nextParagraph = _subtitle.Paragraphs.ElementAtOrDefault(index + 1); if (nextParagraph != null) { - var distance = paragraph.StartTime.TotalMilliseconds - nextParagraph.EndTime.TotalMilliseconds; + var distance = nextParagraph.StartTime.TotalMilliseconds - paragraph.EndTime.TotalMilliseconds; // If an overlap threshold is set, don't fix if threshold exceeded if (distance < 0 && Configuration.Settings.BeautifyTimeCodes.OverlapThreshold > 0 && Math.Abs(distance) >= Configuration.Settings.BeautifyTimeCodes.OverlapThreshold)