From 2ae5df05b954bc8c8ddc191ff7a9f8563c7a61b2 Mon Sep 17 00:00:00 2001 From: xomx Date: Wed, 26 Mar 2025 20:10:33 +0100 Subject: [PATCH] Fix "Keep selection when right-click outside of selection" not work issue Make right-click message handler x-margin calculation right. Previously, the incorrectly used unsigned variable (size_t) overflowed with negative numbers due to incorrect calculation of margin size.x (where possible horizontal scrolling was not taken into account...). Fix #16325, close #16332 --- PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index f3ca30fdd..9cde2efe9 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -684,8 +684,8 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa bool rightClickKeepsSelection = ((NppParameters::getInstance()).getSVP())._rightClickKeepsSelection; if (rightClickKeepsSelection) { - size_t clickX = GET_X_LPARAM(lParam); - size_t marginX = execute(SCI_POINTXFROMPOSITION, 0, 0); + LONG clickX = GET_X_LPARAM(lParam); + LONG marginX = static_cast(execute(SCI_POINTXFROMPOSITION, 0, 0)) + static_cast(execute(SCI_GETXOFFSET, 0, 0)); if (clickX >= marginX) { // if right-click in the editing area (not the margins!),