diff --git a/aegisub/src/dialog_spellchecker.cpp b/aegisub/src/dialog_spellchecker.cpp index edb4cd8c4..5e142594c 100644 --- a/aegisub/src/dialog_spellchecker.cpp +++ b/aegisub/src/dialog_spellchecker.cpp @@ -21,15 +21,6 @@ #include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include - #include "dialog_spellchecker.h" #include "ass_dialogue.h" @@ -49,6 +40,15 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include + DialogSpellChecker::DialogSpellChecker(agi::Context *context) : wxDialog(context->parent, -1, _("Spell Checker")) , context(context) @@ -245,14 +245,18 @@ bool DialogSpellChecker::CheckLine(AssDialogue *active_line, int start_pos, int word_start = 0; for (auto const& tok : tokens) { - word_start += tok.length; - if (tok.type != agi::ass::DialogueTokenType::WORD) continue; - if (word_start < start_pos) continue; + if (tok.type != agi::ass::DialogueTokenType::WORD || word_start < start_pos) { + word_start += tok.length; + continue; + } word_len = tok.length; std::string word = text.substr(word_start, word_len); - if (auto_ignore.count(word) || spellchecker->CheckWord(word)) continue; + if (auto_ignore.count(word) || spellchecker->CheckWord(word)) { + word_start += tok.length; + continue; + } auto auto_rep = auto_replace.find(word); if (auto_rep == auto_replace.end()) { @@ -272,7 +276,7 @@ bool DialogSpellChecker::CheckLine(AssDialogue *active_line, int start_pos, int text.replace(word_start, word_len, auto_rep->second); active_line->Text = from_wx(text); *commit_id = context->ass->Commit(_("spell check replace"), AssFile::COMMIT_DIAG_TEXT, *commit_id); - word_start += auto_rep->second.size() - auto_rep->first.size(); + word_start += auto_rep->second.size(); } return false; }