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); SetEvtHandlerEnabled(false);
Freeze(); Freeze();
int from=0,to=0; int from = GetReverseUnicodePosition(GetSelectionStart());
GetSelection(&from,&to); int to = GetReverseUnicodePosition(GetSelectionEnd());
line_text.clear(); line_text.clear();
SetText(text); SetText(text);
// Restore selection SetSelectionU(from, to);
SetSelectionU(GetReverseUnicodePosition(from), GetReverseUnicodePosition(to));
SetEvtHandlerEnabled(true); SetEvtHandlerEnabled(true);
Thaw(); Thaw();