Fix seeking, hope to improve racing

This commit is contained in:
Martijn van Berkel (Flitskikker) 2024-02-10 11:36:07 +01:00
parent a8c1ba2432
commit a669dec3cf

View File

@ -6612,6 +6612,14 @@ namespace Nikse.SubtitleEdit.Forms
SubtitleListview1_SelectedIndexChanged(null, null);
}
private void SelectListViewIndexAndEnsureVisible(Paragraph p)
{
SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged;
SubtitleListview1.SelectIndexAndEnsureVisible(p);
SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged;
SubtitleListview1_SelectedIndexChanged(null, null);
}
private void FindPrevious()
{
if (_findHelper == null)
@ -21996,10 +22004,14 @@ namespace Nikse.SubtitleEdit.Forms
controlSubtitle,
(timeSeconds) =>
{
// Invoke to not interfere with any inserting
BeginInvoke(new Action(() => {
GoToTimeAndSelectPrecedingParagraph(timeSeconds);
}));
},
(newParagraph) =>
{
// Synchronous, so it's (hopefully) done before the next seek
InsertAndSelectParagraph(newParagraph);
}
);
@ -22019,7 +22031,7 @@ namespace Nikse.SubtitleEdit.Forms
// Select correct paragraph
for (int i = 0; i < _subtitle.Paragraphs.Count; i++)
{
if (timeSeconds > _subtitle.Paragraphs[i].EndTime.TotalSeconds)
if (_subtitle.Paragraphs[i].EndTime.TotalSeconds > timeSeconds)
{
index = i - 1;
SelectListViewIndexAndEnsureVisible(index);
@ -22075,7 +22087,7 @@ namespace Nikse.SubtitleEdit.Forms
// Select it if needed
if (selectInsertedParagraph)
{
SubtitleListview1.SelectIndexAndEnsureVisible(paragraph);
SelectListViewIndexAndEnsureVisible(paragraph);
}
UpdateSourceView();