Fix for "Spell check" auto-fix name - thx Chamallow :)

This commit is contained in:
Nikolaj Olsson 2016-02-08 18:15:42 +01:00
parent c37146aebc
commit c79317c527
2 changed files with 26 additions and 11 deletions

View File

@ -290,7 +290,7 @@ namespace Nikse.SubtitleEdit.Core.SpellCheck
public bool HasName(string word)
{
return _namesEtcList.Contains(word) || (word.StartsWith('\'') || word.EndsWith('\'')) && _namesEtcList.Contains(word.Trim('\''));
return _namesEtcList.Contains(word) || ((word.StartsWith('\'') || word.EndsWith('\'')) && _namesEtcList.Contains(word.Trim('\'')));
}
public bool HasNameExtended(string word, string text)

View File

@ -631,18 +631,33 @@ namespace Nikse.SubtitleEdit.Forms
DoAction(SpellCheckAction.ChangeAll);
return;
}
if (AutoFixNames && _currentWord.Length > 3 && suggestions.Contains(_currentWord.ToUpper()))
if (AutoFixNames && _currentWord.Length > 1)
{
if (_currentWord.Length > 3 && suggestions.Contains(_currentWord.ToUpper()))
{ // does not work well with two letter words like "da" and "de" which get auto-corrected to "DA" and "DE"
ChangeWord = _currentWord.ToUpper();
DoAction(SpellCheckAction.ChangeAll);
return;
}
if (AutoFixNames && _currentWord.Length > 1 && _spellCheckWordLists.HasName(char.ToUpper(_currentWord[0]) + _currentWord.Substring(1)))
if (_spellCheckWordLists.HasName(char.ToUpper(_currentWord[0]) + _currentWord.Substring(1)))
{
ChangeWord = char.ToUpper(_currentWord[0]) + _currentWord.Substring(1);
DoAction(SpellCheckAction.ChangeAll);
return;
}
if (_currentWord.Length > 3 && _currentWord.StartsWith("mc", StringComparison.InvariantCultureIgnoreCase) && _spellCheckWordLists.HasName(char.ToUpper(_currentWord[0]) + _currentWord.Substring(1, 1 ) + char.ToUpper(_currentWord[2]) + _currentWord.Remove(0, 3)))
{
ChangeWord = char.ToUpper(_currentWord[0]) + _currentWord.Substring(1, 1) + char.ToUpper(_currentWord[2]) + _currentWord.Remove(0, 3);
DoAction(SpellCheckAction.ChangeAll);
return;
}
if (_spellCheckWordLists.HasName(_currentWord.ToUpperInvariant()))
{
ChangeWord = _currentWord.ToUpperInvariant();
DoAction(SpellCheckAction.ChangeAll);
return;
}
}
if (_prefix != null && _prefix == "''" && _currentWord.EndsWith("''"))
{
_prefix = string.Empty;