Fix a case where the found text would not be selected with find/replace

SubsTextEditCtrl::SetTextTo needs to update the selection via the text
selection controller or the text selection controller will have an
outdated cached state until the UpdateUI event is processed, which
soemtimes resulted in it not actually setting the selection when it
needed to be.
This commit is contained in:
Thomas Goyne 2014-07-01 20:10:24 -07:00
parent abcd2bd61b
commit a084f02a2d

View file

@ -37,6 +37,7 @@
#include "include/aegisub/context.h"
#include "include/aegisub/spellchecker.h"
#include "selection_controller.h"
#include "text_selection_controller.h"
#include "thesaurus.h"
#include "utils.h"
@ -310,10 +311,18 @@ void SubsTextEditCtrl::SetTextTo(std::string const& text) {
auto old_pos = agi::CharacterCount(line_text.begin(), line_text.begin() + insertion_point, 0);
line_text.clear();
SetSelection(0, 0);
SetTextRaw(text.c_str());
auto pos = agi::IndexOfCharacter(text, old_pos);
SetSelection(pos, pos);
if (context) {
context->textSelectionController->SetSelection(0, 0);
SetTextRaw(text.c_str());
auto pos = agi::IndexOfCharacter(text, old_pos);
context->textSelectionController->SetSelection(pos, pos);
}
else {
SetSelection(0, 0);
SetTextRaw(text.c_str());
auto pos = agi::IndexOfCharacter(text, old_pos);
SetSelection(pos, pos);
}
SetEvtHandlerEnabled(true);
Thaw();