forked from mia/Aegisub
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:
parent
abcd2bd61b
commit
a084f02a2d
1 changed files with 13 additions and 4 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue