From 5bc094e12a3b1334ec712537c4e6bf42c8a0c718 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Thu, 28 Oct 2021 14:08:53 +0200 Subject: [PATCH] Improve conhost CPU usage during text selection (#11634) --- src/host/selection.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/host/selection.cpp b/src/host/selection.cpp index 7814bfae9..90bb5668f 100644 --- a/src/host/selection.cpp +++ b/src/host/selection.cpp @@ -255,6 +255,14 @@ void Selection::ExtendSelection(_In_ COORD coordBufferPos) srNewSelection.Top = _coordSelectionAnchor.Y; } + // This function is called on WM_MOUSEMOVE. + // Prevent triggering an invalidation just because the mouse moved + // in the same cell without changing the actual (visible) selection. + if (_srSelectionRect == srNewSelection) + { + return; + } + // call special update method to modify the displayed selection in-place // NOTE: Using HideSelection, editing the rectangle, then ShowSelection will cause flicker. //_PaintUpdateSelection(&srNewSelection);