From 27c86016465bc37706371d5bc9653e8321c3565d Mon Sep 17 00:00:00 2001 From: Andreas Falkenhahn Date: Tue, 5 Jan 2016 01:21:45 +0100 Subject: [PATCH] Avoid unnecessary selection changes in wxMSW wxTextCtrl::GetStyle() We don't need to change the selection if we're interested in the attribute of its starting position, as is typically the case because this is also the cursor position, because EM_GETCHARFORMAT returns the attribute of the first character of the selection and not, as was apparently believed when this code was written, only the attributes which are the same for the whole selection. This avoids flicker when constantly using GetStyle() to check for the format at the cursor position as the selection is not changed all the time any more. --- src/msw/textctrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index e7f90103a8..e055f1a31d 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -2936,7 +2936,7 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style) GetSelection(&startOld, &endOld); // but do we really have to change the selection? - bool changeSel = position != startOld || position != endOld; + const bool changeSel = position != startOld; if ( changeSel ) {