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
This commit is contained in:
xomx 2025-03-26 20:10:33 +01:00 committed by Don Ho
parent 6bc7abb021
commit 2ae5df05b9

View File

@ -684,8 +684,8 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
bool rightClickKeepsSelection = ((NppParameters::getInstance()).getSVP())._rightClickKeepsSelection; bool rightClickKeepsSelection = ((NppParameters::getInstance()).getSVP())._rightClickKeepsSelection;
if (rightClickKeepsSelection) if (rightClickKeepsSelection)
{ {
size_t clickX = GET_X_LPARAM(lParam); LONG clickX = GET_X_LPARAM(lParam);
size_t marginX = execute(SCI_POINTXFROMPOSITION, 0, 0); LONG marginX = static_cast<LONG>(execute(SCI_POINTXFROMPOSITION, 0, 0)) + static_cast<LONG>(execute(SCI_GETXOFFSET, 0, 0));
if (clickX >= marginX) if (clickX >= marginX)
{ {
// if right-click in the editing area (not the margins!), // if right-click in the editing area (not the margins!),