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.
This commit is contained in:
Andreas Falkenhahn
2016-01-05 01:21:45 +01:00
committed by Vadim Zeitlin
parent 527c25b898
commit 27c8601646

View File

@@ -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 )
{