Spell check undo

This commit is contained in:
niksedk 2014-06-19 16:45:09 +02:00
parent e594383e03
commit 097ec3f178
2 changed files with 5 additions and 4 deletions

View File

@ -267,6 +267,7 @@ namespace Nikse.SubtitleEdit.Forms
private void ButtonAddToDictionaryClick(object sender, EventArgs e) private void ButtonAddToDictionaryClick(object sender, EventArgs e)
{ {
PushUndo(string.Format("{0}: {1}", Configuration.Settings.Language.SpellCheck.AddToUserDictionary, textBoxWord.Text), SpellCheckAction.AddToDictionary);
DoAction(SpellCheckAction.AddToDictionary); DoAction(SpellCheckAction.AddToDictionary);
} }
@ -1204,6 +1205,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
var undo = _undoList[_undoList.Count - 1]; var undo = _undoList[_undoList.Count - 1];
_currentIndex = undo.CurrentIndex - 1; _currentIndex = undo.CurrentIndex - 1;
_wordsIndex = int.MaxValue-1;
_noOfSkippedWords = undo.NoOfSkippedWords; _noOfSkippedWords = undo.NoOfSkippedWords;
_noOfChangedWords = undo.NoOfChangedWords; _noOfChangedWords = undo.NoOfChangedWords;
_noOfCorrectWords = undo.NoOfCorrectWords; _noOfCorrectWords = undo.NoOfCorrectWords;
@ -1229,7 +1231,7 @@ namespace Nikse.SubtitleEdit.Forms
case SpellCheckAction.AddToDictionary: case SpellCheckAction.AddToDictionary:
_userWordList.Remove(undo.UndoWord); _userWordList.Remove(undo.UndoWord);
_userPhraseList.Remove(undo.UndoWord); _userPhraseList.Remove(undo.UndoWord);
Utilities.AddToUserDictionary(undo.UndoWord, _languageName); Utilities.RemoveFromUserDictionary(undo.UndoWord, _languageName);
break; break;
case SpellCheckAction.AddToNamesEtc: case SpellCheckAction.AddToNamesEtc:
if (undo.UndoWord.Length > 1 && _namesEtcList.Contains(undo.UndoWord)) if (undo.UndoWord.Length > 1 && _namesEtcList.Contains(undo.UndoWord))
@ -1249,7 +1251,7 @@ namespace Nikse.SubtitleEdit.Forms
if (!undo.UndoWord.EndsWith("'")) if (!undo.UndoWord.EndsWith("'"))
_namesEtcListWithApostrophe.Remove(undo.UndoWord + "'"); _namesEtcListWithApostrophe.Remove(undo.UndoWord + "'");
Utilities.RemoveFromLocalNamesEtcList(ChangeWord, _languageName); Utilities.RemoveFromLocalNamesEtcList(undo.UndoWord, _languageName);
} }
break; break;
case SpellCheckAction.ChangeWholeText: case SpellCheckAction.ChangeWholeText:

View File

@ -2009,7 +2009,6 @@ namespace Nikse.SubtitleEdit.Logic
if (w.Length > 0 && w != word) if (w.Length > 0 && w != word)
words.Add(w); words.Add(w);
} }
words.Add(word);
words.Sort(); words.Sort();
userWords.DocumentElement.RemoveAll(); userWords.DocumentElement.RemoveAll();
@ -2064,7 +2063,7 @@ namespace Nikse.SubtitleEdit.Logic
var localNamesEtc = new List<string>(); var localNamesEtc = new List<string>();
string userNamesEtcXmlFileName = LoadLocalNamesEtc(localNamesEtc, localNamesEtc, languageName); string userNamesEtcXmlFileName = LoadLocalNamesEtc(localNamesEtc, localNamesEtc, languageName);
if (localNamesEtc.Contains(word)) if (!localNamesEtc.Contains(word))
return false; return false;
localNamesEtc.Remove(word); localNamesEtc.Remove(word);
localNamesEtc.Sort(); localNamesEtc.Sort();