From 14d94375b2d0956fcec26e1ba6a3daacefd50d25 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Tue, 13 Sep 2016 22:17:38 +0200 Subject: [PATCH] Shortcut "Set end, add new and go to new" now tries to use min gap - thx Grega :) --- src/Forms/Main.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index 3d630ba27..2c2e40aa8 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -11521,11 +11521,19 @@ namespace Nikse.SubtitleEdit.Forms int index = SubtitleListview1.SelectedItems[0].Index; MakeHistoryForUndoOnlyIfNotResent(string.Format(_language.VideoControls.BeforeChangingTimeInWaveformX, "#" + _subtitle.Paragraphs[index].Number + " " + _subtitle.Paragraphs[index].Text)); - _subtitle.Paragraphs[index].EndTime = TimeCode.FromSeconds(videoPosition); + var p = _subtitle.Paragraphs[index]; + p.EndTime = TimeCode.FromSeconds(videoPosition); + if (p.Duration.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines > Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds) + { + var newEndTime = new TimeCode(p.EndTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines); + double charactersPerSecond = Utilities.GetCharactersPerSecond(new Paragraph(p) { EndTime = newEndTime }); + if (charactersPerSecond <= Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds) + { + p.EndTime = newEndTime; + } + } SubtitleListview1.SetStartTimeAndDuration(index, _subtitle.Paragraphs[index]); - SetDurationInSeconds(_subtitle.Paragraphs[index].Duration.TotalSeconds); - ButtonInsertNewTextClick(null, null); } }