From af507a98f4c186600dd891074145055c7a0c5af2 Mon Sep 17 00:00:00 2001 From: niksedk Date: Sat, 24 Dec 2011 12:16:16 +0000 Subject: [PATCH] Fixed bug undo (Ctrl+z invoked very fast after a change) git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@855 99eadd0c-20b8-1223-b5c4-2a2b2df33de2 --- src/ChangeLog.txt | 2 +- src/Forms/Main.cs | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog.txt b/src/ChangeLog.txt index 010867da0..ee7aec9c6 100644 --- a/src/ChangeLog.txt +++ b/src/ChangeLog.txt @@ -14,13 +14,13 @@ Subtitle Edit Changelog Now includes (some) italic detection + adds support for Arabic, Hebrew, Hindi, and Thai * Undo improved so it also works for textbox + redo (Ctrl+Y) + * Many new configurable shortcuts * OCR tweaked a bit + BluRay sup files are processed faster * TextBox with current subtitle now shows cursor position - thx Leszek * Subtitle format PAC much improved * Subtitle format FCP Xml improved - thx Ulrik * Subtitle format D-Cinema improved - thx Karam * Splitting of lines - Thx Trottel - * More configurable shortcuts * FIXED: * Fixed crash when setting Options - thx karmazyn * Fixed crash in set color (or set font) - thx LEO33 diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index 9448642eb..09ee54605 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -3682,8 +3682,21 @@ namespace Nikse.SubtitleEdit.Forms UndoToIndex(true); } + /// + /// Undo or Redo + /// + /// True equals undo, false triggers redo private void UndoToIndex(bool undo) { + // Add latest changes if any (also stop changes from being added while redoing/undoing) + timerTextUndo.Stop(); + timerAlternateTextUndo.Stop(); + _listViewTextTicks = 0; + _listViewAlternateTextTicks = 0; + timerTextUndo_Tick(null, null); + timerAlternateTextUndo_Tick(null, null); + + int selectedIndex = FirstSelectedIndex; string text = string.Empty; if (undo) @@ -3731,9 +3744,6 @@ namespace Nikse.SubtitleEdit.Forms _fileName = _subtitle.UndoHistory(_undoIndex, out subtitleFormatFriendlyName, out _fileDateTime, out _subtitleAlternate, out _subtitleAlternateFileName); if (!undo) { - if (_subtitle.HistoryItems[_undoIndex].RedoParagraphs == null) //TODO: why? Fast keypresses? - return; - _subtitle.Paragraphs.Clear(); if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null) _subtitleAlternate.Paragraphs.Clear(); @@ -3787,8 +3797,10 @@ namespace Nikse.SubtitleEdit.Forms if (_subtitleAlternate != null && _subtitle.HistoryItems[_undoIndex].RedoLineIndex >= 0 && _subtitle.HistoryItems[_undoIndex].RedoLineIndex == FirstSelectedIndex) textBoxListViewTextAlternate.SelectionStart = _subtitle.HistoryItems[_undoIndex].RedoLinePositionAlternate; - ShowStatus("Redo performed"); //TODO:WORKING ON UNDO + ShowStatus("Redo performed"); //TODO: do not hardcode text... SE 3.3 } + timerTextUndo.Start(); + timerAlternateTextUndo.Start(); } private void RedoLastAction()