From b9b804ff552f84fbf12e52e5dccbbfb48c79f88a Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 10 Jul 2013 18:03:17 -0700 Subject: [PATCH] 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. --- aegisub/src/subs_edit_ctrl.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/aegisub/src/subs_edit_ctrl.cpp b/aegisub/src/subs_edit_ctrl.cpp index 7ad11e153..900e88bbb 100644 --- a/aegisub/src/subs_edit_ctrl.cpp +++ b/aegisub/src/subs_edit_ctrl.cpp @@ -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();