Fix selection preserving in SubsTextEditCtrl::SetTextTo

Calling GetReverseUnicodePosition on the selection positioning after
calling SetText resulted in the conversions between UTF-8 indices and
wxString indices just being a very slow no-op.
This commit is contained in:
Thomas Goyne 2013-07-10 18:03:17 -07:00
parent 8ab163cb5a
commit b9b804ff55
1 changed files with 3 additions and 4 deletions

View File

@ -279,14 +279,13 @@ void SubsTextEditCtrl::SetTextTo(wxString const& text) {
SetEvtHandlerEnabled(false);
Freeze();
int from=0,to=0;
GetSelection(&from,&to);
int from = GetReverseUnicodePosition(GetSelectionStart());
int to = GetReverseUnicodePosition(GetSelectionEnd());
line_text.clear();
SetText(text);
// Restore selection
SetSelectionU(GetReverseUnicodePosition(from), GetReverseUnicodePosition(to));
SetSelectionU(from, to);
SetEvtHandlerEnabled(true);
Thaw();