Fix URL is opened inadvertently when clicking white space outside document
Fix #8581, close #8584
This commit is contained in:
parent
efd7b56af9
commit
b724a04eeb
@ -817,18 +817,19 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
// Check wether cursor is within URL
|
// Check wether cursor is within URL
|
||||||
auto indicMsk = notifyView->execute(SCI_INDICATORALLONFOR, notification->position);
|
auto indicMsk = notifyView->execute(SCI_INDICATORALLONFOR, notification->position);
|
||||||
if (!(indicMsk & (1 << URL_INDIC))) break;
|
if (!(indicMsk & (1 << URL_INDIC))) break;
|
||||||
|
auto startPos = notifyView->execute(SCI_INDICATORSTART, URL_INDIC, notification->position);
|
||||||
// Revert selection of current word. Best to this early, otherwise the
|
auto endPos = notifyView->execute(SCI_INDICATOREND, URL_INDIC, notification->position);
|
||||||
// selected word is visible all the time while the browser is starting
|
if ((notification->position < startPos) || (notification->position > endPos)) break;
|
||||||
notifyView->execute(SCI_SETSEL, notification->position, notification->position);
|
|
||||||
|
|
||||||
// WM_LBUTTONUP goes to opening browser instead of Scintilla here, because the mouse is not captured.
|
// WM_LBUTTONUP goes to opening browser instead of Scintilla here, because the mouse is not captured.
|
||||||
// The missing message causes mouse cursor flicker as soon as the mouse cursor is moved to a position outside the text editing area.
|
// The missing message causes mouse cursor flicker as soon as the mouse cursor is moved to a position outside the text editing area.
|
||||||
::PostMessage(notifyView->getHSelf(), WM_LBUTTONUP, 0, 0);
|
::PostMessage(notifyView->getHSelf(), WM_LBUTTONUP, 0, 0);
|
||||||
|
|
||||||
|
// Revert selection of current word. Best to this early, otherwise the
|
||||||
|
// selected word is visible all the time while the browser is starting
|
||||||
|
notifyView->execute(SCI_SETSEL, notification->position, notification->position);
|
||||||
|
|
||||||
// Open URL
|
// Open URL
|
||||||
auto startPos = notifyView->execute(SCI_INDICATORSTART, URL_INDIC, notification->position);
|
|
||||||
auto endPos = notifyView->execute(SCI_INDICATOREND, URL_INDIC, notification->position);
|
|
||||||
generic_string url = notifyView->getGenericTextAsString(static_cast<size_t>(startPos), static_cast<size_t>(endPos));
|
generic_string url = notifyView->getGenericTextAsString(static_cast<size_t>(startPos), static_cast<size_t>(endPos));
|
||||||
::ShellExecute(_pPublicInterface->getHSelf(), TEXT("open"), url.c_str(), NULL, NULL, SW_SHOW);
|
::ShellExecute(_pPublicInterface->getHSelf(), TEXT("open"), url.c_str(), NULL, NULL, SW_SHOW);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user